Jump to content
  • Advertisement
Sign in to follow this  
pyrokid

qbasic hit collison

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites
Quote:
Original post by pyrokid
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 ???

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 this post


Link to post
Share on other sites
i know all about libries like sdl allegro and stuuf like that but how do i set it up and use it wit qbasic?

Share this post


Link to post
Share on other sites
QBASIC is absolutely obsolete, if you are interested in using an up-to-date basic that is similar to Q-Basic try out one of the following basics:

PureBasic
http://www.purebasic.com/

IBasic
http://www.pyxia.com/

BlitzBasic
http://www.blitzbasic.com/

If you want a free basic language to use do a search on google you will find lots.

Share this post


Link to post
Share on other sites
Quote:
Original post by pyrokid
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


[code snipped]

Hi. I love snake games too - Tron is one of my favorites.

In the first program, you're using x and y as variables for where the head of your snake is, but you're also checking them for color. The reason your program ends right away is that x and y will *always* be <> 0 the first time into your main loop, because you just set them both to 50.

The second program is closer, but fails because C never changes (it's the color of your snake). You need a way to figure out the color of the pixel that the snake head is currently at, but do that *before* you actually draw the snake head, otherwise you'll overwrite your background before you know what color you hit. So, you'll need yet another variable.

The QBasic Help file is pretty much *all* you need for something like this, it's one of the best QBasic programmers' resources. Look up POINT(), and I think that will get you going. There's an on-line version of the help at http://www.qbasicnews.com/qboho/qck-9996.shtml.

Is this a project for class ?

Share this post


Link to post
Share on other sites
this project is for class we have to make a project using graphicks and after words we have to make a slot machine

Share this post


Link to post
Share on other sites
Then I strongly suggest you read up on the help file - in the graphics section, preferably. What did your teacher recommend to do?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!