Computer Science Canada hasch command |
Author: | gsquare567 [ Thu Apr 06, 2006 6:15 pm ] |
Post subject: | hasch command |
here is my text: var charPick,control:string(1) var screenx,charx,chary:int:=0 charPick:="a" control:="p" getch (charPick) if charPick="m" then cls loop getch (control) drawfillbox (0+screenx,0,maxx+screenx,maxy,brightblue) drawfillbox (0+screenx,0,maxx+screenx,100,grey) drawfilloval (100+charx,200+chary,20,20,66) delay (200) drawfilloval (100+charx,200+chary,20,20,brightblue) charx:=charx-1 screenx:=screenx-1 hasch if control="d" then drawfilloval (100+charx,200+chary,20,20,brightblue) charx:=charx+20 drawfilloval (100+charx,200+chary,20,20,66) elsif chary>=1 then if chary>=(-100) then drawfilloval (100+charx,200+chary,20,20,brightblue) chary:=0 drawfilloval (100+charx,200+chary,20,20,66) end if elsif control="a" then drawfilloval (100+charx,200+chary,20,20,brightblue) charx:=charx-20 drawfilloval (100+charx,200+chary,20,20,66) elsif control="w" then drawfilloval (100+charx,200+chary,20,20,brightblue) chary:=chary+200 drawfilloval (100+charx,200+chary,20,20,66) end if end loop end if ok. so this is pretty crappy i just 4got how to put the hasch in there so it runs even wen u dont input a string 4 the getch. ty ![]() |
Author: | RedRogueXIII [ Thu Apr 06, 2006 6:37 pm ] | ||
Post subject: | |||
Trying to see if it has a character or not ? Your post is a little unclear in the program's function. It looks like the beginning of a side scroller game but i'm not quite sure. I havent actually used hasch but I know of some code that can be helpful for keyboard input. Its this 'abnormal' boolean array and it works more or less like this :
It checks to see if the key inside the brackets is pressed so it wont interrupt the flow of the program. Also it can be used for more or less any key, some have "KEY_" prefix while letters and numbers and the space just need to be chars ('A'). Its pretty simple and easy to use. |
Author: | HellblazerX [ Thu Apr 06, 2006 8:08 pm ] | ||
Post subject: | |||
Hasch is a procedure that returns a boolean value, so you can't just put it into your code the way you did. You must use that value in some way, like this:
But it is recommended that you use RedRogue's method with the InputKeyDown. Also, the Input.KeyDown (chars) must be placed in your loop, and not outside it. |
Author: | Clayton [ Sat Apr 08, 2006 5:57 pm ] |
Post subject: | |
what hellblazers saying is that if you are going to use hasch, it is more or less a condition of some sort like "quit when he presses a char, or, if he presses a char then do this" sort of thing |