1. Funny Moves
- Posted by Paul Kerslake <paulk at UNISERVE.COM> Nov 20, 2000
- 468 views
- Last edited Nov 21, 2000
------=_NextPart_000_0007_01C05335.417606C0 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all. I've been working on a simple program that uses get_key() to "move" a = bitmap. It does this by going through a loop to check if the right key = has been pressed and moves it right or left accordingly in increments of = 1. What I'd like to know, is why when I go "left" three times, then hit = "right" it goes left once more, then right. Why is this? And how can I = fix it? -Thanks -Thomas ------=_NextPart_000_0007_01C05335.417606C0 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>Hi all.</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>I've been working on a simple program = that uses=20 get_key() to "move" a bitmap. It does this by going through a loop to = check if=20 the right key has been pressed and moves it right or left accordingly in = increments of 1. What I'd like to know, is why when I go "left" three = times,=20 then hit "right" it goes left once more, then right. Why is this? And = how can I=20 fix it?</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>-Thanks</FONT></DIV> ------=_NextPart_000_0007_01C05335.417606C0--
2. Re: Funny Moves
- Posted by Brian Broker <bkb at CNW.COM> Nov 21, 2000
- 462 views
On Mon, 20 Nov 2000 21:02:55 -0800, Thomas wrote: >Hi all. > >I've been working on a simple program that uses get_key() to "move" a bitmap. It does this by going through a loop to check if the right key has been pressed and moves it right or left accordingly in increments of 1. What I'd like to know, is why when I go "left" three times, then hit "right" it goes left once more, then right. Why is this? And how can I fix it? > >-Thanks >-Thomas Thomas, I'd rather not venture to guess where your problem lies without first examining your code. -- Brian
3. Re: Funny Moves
- Posted by mic _ <stabmaster_ at HOTMAIL.COM> Nov 21, 2000
- 473 views
>What I'd like to know, is why when I go "left" three times, then hit > >"right" it goes left once more, then right. Why is this? And how can >I >fix it? > If you're holding "left" down, then release it and hit "right", there might be a "left" still in the kbd buffer. You might want to try out Michael Bolin's keyread.e (given that you're writing a DOS-program that is). _____________________________________________________________________________________ Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com
4. Re: Funny Moves
- Posted by Al Getz <xaxo at AOL.COM> Nov 21, 2000
- 447 views
can you post the program so we can look at it and comment? --Al
5. Re: Funny Moves
- Posted by Bernie <xotron at PCOM.NET> Nov 21, 2000
- 445 views
On Mon, 20 Nov 2000 21:02:55 -0800, Paul Kerslake <paulk at UNISERVE.COM> wrote: >Hi all. > >I've been working on a simple program that uses get_key() to "move" a bitmap. It does this by going through a loop to check if the right key has been pressed and moves it right or left accordingly in increments of 1. What I'd like to know, is why when I go "left" three times, then hit "right" it goes left once more, then right. Why is this? And how can I fix it? > >-Thanks >-Thomas > Thomas: Look at your loop and see where in your loop you are checking the key. You may be checking the loop after the leftkey is already executed and not before. Bernie
6. Re: Funny Moves
- Posted by Liona Kerslake <paulk at UNISERVE.COM> Nov 21, 2000
- 469 views
Sorry for the enigmatic letter, I don't like to give away what I'm working on 'till it's decent. So, here is the piece of code that's causing the problem: Please and thanks for looking at it. --Thomas ---/\=== --Start your binary! integer action atom LEFT,RIGHT LEFT=333 RIGHT=331 procedure walkLEFT() if action=LEFT then display_image({sides,ups}, walkL[2]) --just BMPs* pause(.1) display_image({sides,ups}, blackout[2]) * display_image({sides,ups}, walkR[2]) * pause(.1) sides+=1 end if end procedure procedure walkRIGHT() if action=RIGHT then display_image({sides,ups}, walkL[2]) pause(.1) display_image({sides,ups}, blackout[2]) display_image({sides,ups}, walkR[2]) pause(.1) sides-=2 end if end procedure procedure walkies() action=get_key() if action=LEFT then walkLEFT() elsif action=RIGHT then walkRIGHT() end if end procedure while 1 do walkies() end while
7. Re: Funny Moves
- Posted by Derek Parnell <dparnell at BIGPOND.NET.AU> Nov 22, 2000
- 434 views
Hi Thomas, I think you're learning lots and your coding style has improved remarkably. Well done. I suspect the problem is that you display first then move to the next position. The usual way to render moving images is ... if image was displayed then hide it at its current position end if move to the new position display the image I'm not expert here so maybe somebody else can elaborate. ------ Derek Parnell Melbourne, Australia (Vote [1] The Cheshire Cat for Internet Mascot) ----- Original Message ----- > Sorry for the enigmatic letter, I don't like to give away what I'm working > on 'till it's decent. So, here is the piece of code that's causing the > problem: Please and thanks for looking at it. > --Thomas > ---/\=== > > --Start your binary! > > integer action > atom LEFT,RIGHT > LEFT=333 > RIGHT=331 > > procedure walkLEFT() > if action=LEFT then > display_image({sides,ups}, walkL[2]) --just BMPs* > pause(.1) > display_image({sides,ups}, blackout[2]) * > display_image({sides,ups}, walkR[2]) * > pause(.1) > sides+=1 > end if > end procedure > > procedure walkRIGHT() > if action=RIGHT then > display_image({sides,ups}, walkL[2]) > pause(.1) > display_image({sides,ups}, blackout[2]) > display_image({sides,ups}, walkR[2]) > pause(.1) > sides-=2 > end if > end procedure > > procedure walkies() > action=get_key() > if action=LEFT then > walkLEFT() > elsif action=RIGHT then > walkRIGHT() > end if > end procedure > > while 1 do > walkies() > end while
8. Re: Funny Moves
- Posted by Lewis Townsend <keroltarr at HOTMAIL.COM> Nov 21, 2000
- 434 views
- Last edited Nov 22, 2000
Hello Thomas, >Hi Thomas, >I think you're learning lots and your coding style has improved remarkably. >Well done. > >I suspect the problem is that you display first then move to the next >position. The usual way to render moving images is ... > > if image was displayed then > hide it at its current position > end if > move to the new position > display the image > >I'm not expert here so maybe somebody else can elaborate. Derek is right. A few other things I noticed about your code... You use "if action=LEFT.." statement in two places: in the loop and in the walkLEFT() procedure. Same for the "RIGHT" action. This is unnesesary but some might condone this redundancy because it looks like you are being extra careful about what you are doing. However, only knowing about the code you have shown, it looks unnesesary. Don't remove the extra "if"s if you think they are really needed but I don't think they are. Also, I notice you have a pause before the erase and after the display. All you really need is one after the display. Maybe a double long one. Again, this is a change that shouln't change the functionality of the program but makes it shorter and more readable. Also in your sides calculations I don't know if it is right or not but I thought left was minus and right was plus. Besides you are not adding the same as you are subtracting. Below I have changed your code to accomodate my suggestions and Derek's. Please try to understand what I have done before you incororate it into your program. You never know I might have put an error in there. ;) > > integer action > > atom LEFT,RIGHT > > LEFT=333 > > RIGHT=331 > > > > procedure walkLEFT() > > display_image({sides,ups}, blackout[2]) > > sides-=1 > > display_image({sides,ups}, walkL[2]) > > display_image({sides,ups}, walkR[2]) > > pause(.2) > > end procedure > > > > procedure walkRIGHT() > > display_image({sides,ups}, blackout[2]) > > sides+=1 > > display_image({sides,ups}, walkL[2]) > > display_image({sides,ups}, walkR[2]) > > pause(.2) > > end procedure > > > > procedure walkies() > > action=get_key() > > if action=LEFT then > > walkLEFT() > > elsif action=RIGHT then > > walkRIGHT() > > end if > > end procedure > > > > while 1 do > > walkies() > > end while _____________________________________________________________________________________ Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com
9. Re: Funny Moves
- Posted by Al Getz <xaxo at AOL.COM> Nov 21, 2000
- 453 views
- Last edited Nov 22, 2000
K, Looks to me like you should be updating the variable 'sides' BEFORE calling 'display(...)'. What your seeing now when calling 'display(..)' is probably the remnant of the last 'sides' update from a previous call rather then what you really want. Thats if i understand your code fragments correctly... for example: sides+=1 display(...) Good luck with it. --Al