03-18-2024, 07:07 PM
(This post was last modified: 03-18-2024, 07:15 PM by aliensoldier.)
(03-18-2024, 01:00 AM)1micha.elok Wrote:(03-17-2024, 03:24 PM)aliensoldier Wrote: I share with you a simplified version of arkanoid...
Your arkanoid is "rompe-ladriollos del mundo"
note : Is it correct to say "brick breaker of the world" in Spanish ?
Yeah that's right. "rompe-ladrillo del mundo"
(03-18-2024, 06:19 PM)Marcus Wrote: Very nice, very retroThe translator translates in his own way.
It's kind of hard to get the ball where you want it, lots of waiting. Nothing wrong with that. If I rememeber correctly, that's the way it worked in the good old days too! But I've modified your collision_ball function (player.n7) so that it's possible to aim a little.
If the ball bounces on the left part of the paddle, the ball goes left. The more left on the paddle, the more left it goes. Same thing with the right side. If the ball hits the absolute center of the paddle, the ball goes straight up. That's how I usually make the controls for breakout games.
I don't think it's the "spin" thing you asked for, because I didn't quite understand what you meant.
Code:player.collision_ball = function()
if collision_rect(this.x,this.y,this.Width,this.Height,this.ball.x,this.ball.y+this.ball.velocity_y,this.ball.Width,this.ball.Height)
play sound sound_bounce,0.7
' Marcus.
'this.ball.velocity_y = abs(this.ball.velocity_y)
' Calculate the current speed.
speed = sqr(this.ball.velocity_x^2 + this.ball.velocity_y^2)
' Distance in x from ball center to paddle center, dx will be ~[-0.5..0.5].
dx = (this.ball.x + this.ball.Width/2 - (this.x + this.Width/2))/this.Width
' set dy to -0.4, so that you get a good range of possible bounces. You can
' experiment with different values. Lower values mean wider range of angles, it should
' be less than 0.5 though.
dy = -0.4
' Create new velocities by normalizing (dx dy). That is, recalculate the length of
' (dx dy) so that it is 1 but still points in the exact same direction.
k = 1/sqr(dx*dx + dy*dy)
dx = k*dx
dy = k*dy
' Now multiply dx and dy with speed, so that the speed of the ball doesn't change from
' what it was before.
dx = dx*speed
dy = dy*speed
' Set ball velocity (while testing this I noticed that the ball is moving with its
' negative direction, which made me confused :) ).
this.ball.velocity_x = -dx
this.ball.velocity_y = -dy
endif
endfunc
I have noticed a problem with your code, while playing it happened that the ball got stuck on the right side of the screen.
I'll give you a video of the Super Nintendo game Arkanoid in case you want to play this game a little on the emulator and check what I say about handling the direction of the ball.
https://www.youtube.com/watch?v=7O2Xjpk7a-M
(03-17-2024, 05:42 PM)johnno56 Wrote: Nicely done! Those multi-hit bricks gave the ball a work out.... Good job!
I have to think of a way to increase the difficulty in the games I'm making because they're too easy.