Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 hasch command
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
gsquare567




PostPosted: 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 Wink
Sponsor
Sponsor
Sponsor
sponsor
RedRogueXIII




PostPosted: Thu Apr 06, 2006 6:37 pm   Post subject: (No 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 :
code:

var chars : array char of boolean
Input.KeyDown (chars)
    if chars (KEY_UP_ARROW) then
        x += 10
    end if

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.
HellblazerX




PostPosted: Thu Apr 06, 2006 8:08 pm   Post subject: (No 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:

code:
if hasch then
....
end if
%or
exit when hasch

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.
Clayton




PostPosted: Sat Apr 08, 2006 5:57 pm   Post subject: (No 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
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: