Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Vile Smile on October 17, 2010, 08:56:40 pm

Title: Pong Bounce
Post by: Vile Smile on October 17, 2010, 08:56:40 pm
In my pong game, I have a paddle and a ball. My goal is to get the ball to bounce in a direction depending on the contact position, so if the ball hits the upper part of the paddle, it will bounce up, and if it hits the lower part, it will bounce down. I've accomplished this with the following code:
Code: [Select]
:(Y-A)->VY is the ball's position.
A is the paddle's position.
V is the ball's speed.

This works, but causes the ball to move up and down much too fast. So I decided to change the code to the following:
Code: [Select]
:(Y-A)/2->V

This works when the ball is hit down, but when it hits the upper part of the paddle, the ball squiggles up and down until it is hit by the next paddle.

TL;DR
: What is a good way to make a ball bounce against the paddle depending on where the ball and the paddle collide?


Also, as a unrelated question, how would I create a full screen image, such as a title screen?
Title: Re: Pong Bounce
Post by: calc84maniac on October 17, 2010, 08:57:44 pm
You need to do signed division.
Code: [Select]
:(Y-A)//2->Vshould work.
Title: Re: Pong Bounce
Post by: Vile Smile on October 17, 2010, 09:03:28 pm
You need to do signed division.
Code: [Select]
:(Y-A)//2->Vshould work.
Thanks! BTW, is your avatar related to a game you've made or that is available?


Also, does someone have an answer for the second question?
Title: Re: Pong Bounce
Post by: AngelFish on October 17, 2010, 09:03:51 pm

Also, as a unrelated question, how would I create a full screen image, such as a title screen?

Not easily. You would have to design the whole menu, using bitmaps and probably sprites. Basically, you just have to draw all of the graphics from data. The data and menu engine will increase your program size by at least a kilobyte.

EDIT: Calc's avatar comes from his port of F-Zero, which I believe is still in production.
Title: Re: Pong Bounce
Post by: nemo on October 17, 2010, 09:10:55 pm
a title screen would be easy to import. do you already have the screen in a Pic variable? then you could just do Copy([Pic#],L6,768) in your program and the picture variable will be copied to the buffer
Title: Re: Pong Bounce
Post by: ztrumpet on October 17, 2010, 09:49:09 pm
a title screen would be easy to import. do you already have the screen in a Pic variable? then you could just do Copy([Pic#],L6,768) in your program and the picture variable will be copied to the buffer
Actually, if you just want to display it it's even easier.  Just do this:
[Pic#]->DispGraph

Welcome here Vile Smile!  Awesome Avatar and username by the way. :)
Title: Re: Pong Bounce
Post by: Vile Smile on October 17, 2010, 09:56:40 pm
a title screen would be easy to import. do you already have the screen in a Pic variable? then you could just do Copy([Pic#],L6,768) in your program and the picture variable will be copied to the buffer
Actually, if you just want to display it it's even easier.  Just do this:
[Pic#]->DispGraph


Welcome here Vile Smile!  Awesome Avatar and username by the way. :)

Thanks for the welcome! :)

So I'd just use a large hexidecimal code like with sprites?
Title: Re: Pong Bounce
Post by: AngelFish on October 17, 2010, 09:58:25 pm
That'd be the easiest. If you want an interactive menu (or greyscale), it would take a slightly different approach.
Title: Re: Pong Bounce
Post by: Vile Smile on October 17, 2010, 10:05:17 pm
Sorry to continue this, but is there a program that can generate a hexidecimal code that could fit on the entire screen?
Title: Re: Pong Bounce
Post by: Quigibo on October 17, 2010, 10:07:20 pm
If its full screen, its MUCH easier to just import the picture, no codes required.  Just put it in a picture variable and then do what nemo or ztrumpet suggested (depending on your needs).  The compiler will automatically convert the picture into data when it compiles as if you had the hex codes there.
Title: Re: Pong Bounce
Post by: DJ Omnimaga on October 17, 2010, 11:59:48 pm
You need to do signed division.
Code: [Select]
:(Y-A)//2->Vshould work.
Thanks! BTW, is your avatar related to a game you've made or that is available?
A game that only him and myself currently have on our computer ;D I think he stopped working on it for a while, though.

Welcome here by the way :)

Also for title screens, if your screen got huge gaps of white or black horizontally, sometimes it may be best to just store parts of it then recall each parts at the appropriate location the fill the remaining stuff with a black rectangle or something. That saves quite a bit of space.