Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411516 Posts in 69376 Topics- by 58431 Members - Latest Member: Bohdan_Zoshchenko

April 27, 2024, 08:12:40 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)help with Arkanoid style ball bounce... please
Pages: [1]
Print
Author Topic: help with Arkanoid style ball bounce... please  (Read 2966 times)
Randy
Level 0
***



View Profile WWW
« on: April 07, 2009, 05:11:40 AM »

Hello

There is probably has an easy answer but I can't figure it out.  See, I'm super new to the Game Maker scene and don't know much about such things.  I've been able to make a breakout/arkanoid style game on my own.  Pretty simple... I know...  but now I'm wanting to see if I can add some of the Arkanoid ball physics do the game.  You know, how if you move the paddle in the opposite way the ball is traveling you can change it's direction.  To give the player more control over the ball and not just a slave to bounce angles.  But I can't seem to do it with the drag and drop system.

So I thought I'd swing my way over here and ask and see if anyone can help me.

Thanks in advance ^_^

Randy
« Last Edit: April 07, 2009, 09:23:18 AM by Randy » Logged
Lynx
Level 5
*****


Upstart Feline Miscreant


View Profile WWW
« Reply #1 on: April 07, 2009, 09:18:56 AM »

The way I'm handling this is to transfer some of the paddle's momentum to the ball at the point of contact.  I store a number based on how much the paddle moved in the last half second or so.  Maybe you can do something like this in GM; I haven't used that so I don't know.
Logged

Currently developing dot sneak - a minimalist stealth game
ChevyRay
Guest
« Reply #2 on: April 07, 2009, 09:31:54 AM »

Game Maker actually stores a local variable in all objects called xprevious, which you could use to this purpose. You could do something like this, to calculate how much the paddle moved in the last step (sort of what Lynx was suggesting)...

Code:
xoffset = x - xprevious;

With drag and drop, this would be the equivalent of just setting a local variable to the value x - xprevious.

So if you were moving to the right, it would be a positive value, and if you were moving to the left, it'd be a negative value. When the ball hits the paddle, you could just add this motion to the ball's motion.

For example, in the collision-with-paddle event for the ball...

Code:
hspeed += other.xoffset;

Without setting a variable, it would look something like this:

Code:
hspeed += (other.x - other.xprevious);

If you're storing the paddle's movement in a speed variable already, you could probably just use that variable. For example, if it used a constant moving speed... like 4 pixels/step, then when the ball hit's the paddle, you'd want to increase its hspeed by 4 if the paddle is moving right, and decrease it by 4 if the paddle is moving left.

So yeah, there's multiple approaches to this, but hopefully this cleared up the general idea. If you need help implementing these codes, or doing so in DnD, just let me know Smiley
Logged
Randy
Level 0
***



View Profile WWW
« Reply #3 on: April 07, 2009, 11:35:49 AM »

Wow ChevyRay... I never realized how not programmery I am until I tried to make my own games (damn inner artist).  I'm going to push forward though.

So yeah... I would love some help on a D&D method you just mentioned.  I don't think I'm ready for code just yet.  Soon though as I see more and more that others just use the code to get things done and it seems a lot better to keep organized.
Logged
ChevyRay
Guest
« Reply #4 on: April 12, 2009, 12:27:13 AM »

Here you go buddy. This is a very simple D&D example of what I think you're trying to accomplish. Basically the ball starts moving, and I made it so the paddle movement influences the direction of the ball. Peace Smiley

(right-click and save as)
http://properundead.com/examples/arktest.gmk

Let me know if you have any trouble with it.

EDIT: on a side note, it was TRIPPY programming in D&D. I haven't used it at all in like 4 years now, and it took me awhile to figure out how the heck to get this to work :D

EDIT2:
Quote
I never realized how not programmery I am until I tried to make my own games (damn inner artist).  I'm going to push forward though.
Yeah, definitely don't let yourself be intimidated! It only gets easier and easier. Look at Carnivac; he's constantly telling me that he's no good at programming and is more the artist type, yet his game is almost demo-ready, and pretty damn-fine for a "non-programmer" if you ask me. Roll Eyes
« Last Edit: April 12, 2009, 12:33:17 AM by ChevyRay » Logged
Randy
Level 0
***



View Profile WWW
« Reply #5 on: April 20, 2009, 08:52:09 AM »

Sorry for the delay in getting back to ya... I was painting that Samus picture ^_^

So I looked at what you did (thank you very much by the way) and it works perfectly but if the paddle is stationary the the ball just bounces up.

I'm still not versed enough in code to understand what I should be doing and I'm looking in to examples, or how to's to learn more.

Any more tips anyone could provide would be super appreciated. ^_^

Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic