Public Group

# qbasic hit collison

This topic is 5459 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

i am a new programer i know how to use qbasic very well and also visual basic is got intrsted in making games and im starting from low to high low as qbasic i ave a qbasic class in school i started to make a game sort of like snake but u just see how long u can sirvive with out hiting the wall or ur self also there is 2 player i can do most of the stuff my self but i cant seem to be able to do the hit colision i tries putting IF x or y <> 0 THEN END 0 is black the background is black and if it hits something not black u die. my code is this but i just started it its not big yet can someone tell me wat im doing wrong or how to do this CLS SCREEN 9 LINE (20, 1)-(630, 330), 3, B REM this is a box a boundry x = 50 y = 50 DO c = 14 press$= INKEY$ PSET (x, y), c IF y > 1 THEN IF press$= "w" THEN y = y - 1 IF y < 330 THEN IF press$ = "s" THEN y = y + 1 IF x > 20 THEN IF press$= "a" THEN x = x - 1 IF x < 630 THEN IF press$ = "d" THEN x = x + 1 IF x <> 0 THEN END IF y <> 0 THEN END LOOP UNTIL press$= CHR$(27) IVE ALSO TRIED CLS SCREEN 9 LINE (20, 1)-(630, 330), 3, B x = 50 y = 50 xl = 50 yl = 50 DO c = 14 press$= INKEY$ PSET (x, y), c IF y > 1 THEN IF press$= "w" THEN y = y - 1 IF y < 330 THEN IF press$ = "s" THEN y = y + 1 IF x > 20 THEN IF press$= "a" THEN x = x - 1 IF x < 630 THEN IF press$ = "d" THEN x = x + 1 IF C <> 0 THEN END LOOP UNTIL press$= CHR$(27)

##### Share on other sites
i also have 1 more question how do i get it so when i press w once or s once it will keep moving that direction till another directional key is pressed ???

##### Share on other sites
Quote:
 Original post by pyrokidi also have 1 more question how do i get it so when i press w once or s once it will keep moving that direction till another directional key is pressed ???

It's been forever since I've touched any PC Basic. Anyway, generally you'll keep an array of keys or flags, updating these at each keydown/up event. So when 'w' is pushed, set the array at 'w' (or variable w, or moveLeft or somesuch) to 1 and the opposing flag ('s') to 0. Then, in your main loop, check the status of these and apply physics/motion as necessary.

##### Share on other sites
what do u mean?????
example code???

• 15
• 22
• 16
• 13
• 14