Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
RapidZ
17
Years of Service
User Offline
Joined: 2nd Apr 2007
Location: Corby, Northants
Posted: 31st May 2007 19:31
Hello i have been reading things on forum and they have been helpful. And i managed to create this half done basic 2D game, and i need some help as i am now stuck. I is pong or what ever it is called, i am just stuck on how i would make the circle bounce around off things. Code is bellow, the arros and number pad keys control the moving bars. Kinda messy i think but i am new. If you got any tips then please share



RapidZ - http://thecomputerhideout.com
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 1st Jun 2007 03:44
When I ran the code I got an error on this
Quote: "Text 5,5,\"Mouse X: \"+Str$(MouseX())"
line and the two lines after it. You need to move the first quotation marks to before the first \ in order for it to work correctly.

As to the code, I would recommend that you use sprites for the paddles and the ball. With your code you are clearing the screen and re-drawing everything in each loop, not a real efficient way to do it. You can do it the way you have chosen, but using sprites would be easier and the code will run faster.

For the ball itself, you will need to choose directions in which you want it to move. Typically, this would be six different directions. You change the ball's x/y coordinates based upon the direction it is moving. If it hits a wall or paddle (you'll have to check for this), your code should give an appropriate reaction when something is bounced against. You could even code it so that if it hits near the end of paddle, it will bounce a certain way.

With sprites, you could easily animate the ball and even have it give the appearance of rolling in the correct direction.


Hope this helps.

LB
RapidZ
17
Years of Service
User Offline
Joined: 2nd Apr 2007
Location: Corby, Northants
Posted: 1st Jun 2007 12:15
Thank you i will look into this and try it. The line you got error i made a stupid error. They should be:

Text 5,5,"Mouse X: "+Str$(MouseX())
Text 5,20,"Mouse Y: "+Str$(MouseY())
Text 250,5,"Code: "+str$(scancode())

Those where there just to help me find out the code for each key and coords of the mouse.

RapidZ - http://thecomputerhideout.com

Login to post a reply

Server time is: 2024-09-26 22:48:12
Your offset time is: 2024-09-26 22:48:12