|
Post by Carl Gundel on Dec 31, 2018 11:41:49 GMT -5
Hey everyone. I have been hard at work trying make my end of year deadline for new LB5 alphas. Sorry to say I’m not quite there yet, but the good news is that huge progress has been made. This year there have been nearly 40 internal builds and more than 300 changes to the LB5 codebase.
Probably in another week or so I will have something ready for all of you.
Thanks for your patience, and happy new year!
-Carl
|
|
fox
Junior Member
Posts: 66
|
Post by fox on Dec 31, 2018 13:34:45 GMT -5
Thanks a lot to you, Carl. And happy new year!!! And happy new year to all friends of Forum!!! fox
|
|
hmonnier
New Member
Enjoying Life
Posts: 27
|
Post by hmonnier on Dec 31, 2018 13:57:00 GMT -5
hanks for your efforts, we all are anxious, and patient..... Do have a happy ans safe new year.... Henri
|
|
|
Post by atomose on Dec 31, 2018 14:28:14 GMT -5
Nice news ! thx !
|
|
|
Post by timfung5 on Jan 9, 2019 9:22:09 GMT -5
Hello, Carl, I have a suggestion on version 5. I discover a flaw in version 4.5.1. Please download ETERNAL QUEST here. e-gamer.wixsite.com/gamerIt is a very pretty game. Sure. However, I believe that I find a basic flaw of Liberty BASIC version 4.5.1. The keyboard control of the character! If I press down an arrow key and do not release this arrow key, unnatural things happen. The character walks with one step. Then a small halt appears. Then the character walks continuously. Do you understand what I mean? This situation is not reasonable and not ideal. I hope that there will be no halt in version 5. Thanks a lot!!!!!!!
|
|
|
Post by tsh73 on Jan 9, 2019 9:57:53 GMT -5
timfung5, about "unnatural things happen". It is indeed natural and even desired. It is called typematic delay and introduced in keyboard to ease of typing. Because IBM PC was not gaming machine from the start. Of cource it is not desired for games. Try using GetAsynkKeyState like in this thread Multikey via GetAsincKeyState
|
|
cundo
Full Member
Muchas Gracias!!
Posts: 146
|
Post by cundo on Jan 9, 2019 13:07:44 GMT -5
Hello, Carl, I have a suggestion on version 5. I discover a flaw in version 4.5.1. Please download ETERNAL QUEST here. e-gamer.wixsite.com/gamerIt is a very pretty game. Sure. However, I believe that I find a basic flaw of Liberty BASIC version 4.5.1. The keyboard control of the character! If I press down an arrow key and do not release this arrow key, unnatural things happen. The character walks with one step. Then a small halt appears. Then the character walks continuously. Do you understand what I mean? This situation is not reasonable and not ideal. I hope that there will be no halt in version 5. Thanks a lot!!!!!!! Hi tim, that's not a flaw, it's how movement was coded.
|
|
|
Post by timfung5 on Jan 10, 2019 3:54:19 GMT -5
tsh73, cundo,
Thank you very much!
Will this solution scare many novice learners?
|
|
|
Post by Rod on Jan 10, 2019 4:56:10 GMT -5
Timfung5, the keyboard is actually quite a complex thing. There are things you need to know and handle as a programmer. The first, as you have found, is that if the user presses and holds a key it will autorepeat. You will also find that some keys fire when pressed and again when released.
Here are some programs that show you a bit about the different ways to handle the keyboard. Liberty has no "faults" it allows the programmer to read the keyboard in a variety of ways. Its up to the programmer to choose the correct method for the task at hand.
Take sprite movement, the programmer should react to and record the desired change of direction and use that info on a timed basis. That way the action does not speed up when a stream of keypresses are sent.
nomainwin
'load the bitmaps we'll use as sprites & background 'load smiley1.bmp to use as our sprite 'load bg1.bmp as our background loadbmp "smiley1", "sprites\smiley1.bmp" loadbmp "landscape", "sprites\bg1.bmp"
'open a window and graphicbox WindowHeight = 300 WindowWidth = 400 graphicbox #w.g, 0, 0, 400, 300 open "Use keys l r u d s to move sprite" for window_nf as #w print #w, "trapclose [quit]"
'add the background and sprite to the sprite engine 'add background using bmp landscape 'add a sprite called smiley print #w.g, "background landscape"; print #w.g, "addsprite smiley smiley1"
'set the starting coordinates and movement x = 100 xmovement=0 y = 100 ymovement=0
'start the keyboard checking event print #w.g, "when characterInput [keyboardinterrupt]" print #w.g, "setfocus"
' now start the timer to repeatedly call the drawing loop timer 17, [drawingloop]
'now sit and wait for the first event to trigger wait
[drawingloop] 'this loop gets called every 17ms by the timer event 'add the movement to x and y
'if you go off screen roll round x or y 'x=x+xmovement 'if x<0 then x=399 'if x>399 then x=0 'y=y+ymovement 'if y<0 then y=299 'if y>299 then y=0
'if you hit a wall bounce x=x+xmovement if x<0 then xmovement=0-xmovement if x>399 then xmovement=0-xmovement y=y+ymovement if y<0 then ymovement=0-ymovement if y>299 then ymovement=0-ymovement 'now redraw the sprites print #w.g, " spritexy smiley ";str$(x);" ";str$(y) print #w.g, "drawsprites" wait
[keyboardinterrupt] 'this loop gets called every time a key is pressed 'set the movement depending on key pressed key$=Inkey$ select case key$ case "l" 'left xmovement=-1 case "r" 'right xmovement=1 case "u" 'up ymovement=-1 case "d" 'down ymovement=1 case "s" 'stop xmovement=0 ymovement=0 end select wait
[quit] timer 0 unloadbmp "landscape" unloadbmp "smiley1" close #w
Now this next code shows you how complicated the keyboard messaging can be.
'INKEY.BAS - how to use the Inkey$ variable 'nomainwin
open "Inkey$ example" for graphics as #graph #graph "when characterInput [fetch]" #graph "setfocus" #graph "\\Press any key or key combination" wait
[fetch]
'a key or key combination was pressed, fetch it 'some keys issue a key down and a key up message. For example Shift Control and Enter do so 'Esc issues three messages, press some keys and observe the mainwin data #graph "when characterInput" key$ = Inkey$
'show what we got in the mainwin 'key messages are either one or two bytes long print len(key$), if len(key$)=1 then print "-- ";asc(right$(key$,1)),right$(key$,1) else print right$(" ";asc(left$(key$,1)),2);" ";asc(right$(key$,1)),right$(key$,1) end if
'get the key value of the right most character of a two byte message or 'simply the key value of a single byte message key=asc(right$(key$,1))
'if we have received a a single byte message it is most likely a printable character 'but some system keys like Enter,Tab and Backspace can send single byte messages 'so lets filter out the single byte alpha numeric messages and send the rest on as system key messages if key >=32 and key<=126 and len(key$)=1 then #graph "\";key$
'if we have received a two byte message or a single byte message that is not alpha numeric 'then we have a system key message else 'seek out its virtual keycode value 'Go here for full list http://msdn.microsoft.com/en-us/library/dd375731(VS.85).aspx select case key case 3 #graph "\Ctrl C COPY" case 22 #graph "\Ctrl V PASTE" case _VK_SHIFT #graph "\Shift" case _VK_RETURN #graph "\Enter" case _VK_LEFT #graph "\Left Arrow" case _VK_RIGHT #graph "\Right Arrow" case _VK_UP #graph "\Up Arrow" case _VK_DOWN #graph "\Down Arrow" case _VK_PRIOR #graph "\Page Up" case _VK_NEXT #graph "\Page Down" case _VK_HOME #graph "\Home" case _VK_BACK #graph "\Back" case _VK_END #graph "\End" case _VK_DELETE #graph "\Delete" case _VK_CONTROL #graph "\Control" case else #graph "\Not in list" end select end if
print #graph, "when characterInput [fetch]" print #graph, "setfocus" wait
Finally the "complicated and scary solution" turns out to be quite simple. Again you have to choose when this method would be appropriate, probably in a fast paced graphics game.
'This is a very fast way to check specific keys on the fly 'during program execution. No need for when characterInput 'and associated handler.
print "Press the arrow keys, the space bar, or Esc to exit."
[loop] scan if keyState(_VK_LEFT) then print "Left is pressed." if keyState(_VK_RIGHT) then print "Right is pressed." if keyState(_VK_UP) then print "Up is pressed." if keyState(_VK_DOWN) then print "Down is pressed." if keyState(32) then print "Space is pressed." if keyState(27) then print "Esc pressed. Ended." : end goto [loop]
function keyState(keycode) calldll #user32, "GetAsyncKeyState", _ keycode AS long, _ state AS long if state <> 0 then keyState = 1 '1 = pressed end function
So its more about understanding your tool set than assuming fault.
|
|
|
Post by Rod on Jan 10, 2019 15:10:13 GMT -5
Can you see that the “direction” might be changed many hundreds of times a second by key presses but that the program only uses the information every 17ms? Can you see that the fast loop might change the direction thousands of times a second. Can you visualise that the screen gets painted sixty times a second but we have the ability to draw it thousands of times a second? would we see that drawing?
When you comprehend the power and speed of the machine you begin to truly understand the power of the BASIC command set.
|
|