Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
my third game, simple arkanoid
#1
I share with you a simplified version of arkanoid, to move use the arrows and to pause the "p" key. There are three levels and in each level the ball will move faster.

There is one thing that I have not been able to add and I was looking for how to do it but I did not find anything, I wanted to be able to control the movement of the ball, when the ball collides with the left or the right part of the edge of the player's racket I wanted the ball to If he moved in that direction with spin, like when a soccer player hits the ball with spin, I think it would have been more fun.

I put the missing file here because it won't let me put more than 5 at a time.

To start press the enter key and to start moving the ball press the space key.


Attached Files
.n7   arkanoid.n7 (Size: 6.48 KB / Downloads: 7)
.n7   player.n7 (Size: 2.06 KB / Downloads: 6)
.n7   ball.n7 (Size: 2.8 KB / Downloads: 6)
.n7   brick.n7 (Size: 1.16 KB / Downloads: 6)
.n7   list_brick.n7 (Size: 516 bytes / Downloads: 6)
.n7   miscellaneous.n7 (Size: 1.39 KB / Downloads: 6)
Reply
#2
Nicely done! Those multi-hit bricks gave the ball a work out.... Good job!
Logic is the beginning of wisdom.
Reply
#3
(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 ?  Big Grin
Reply
#4
Very nice, very retro Smile

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
Reply
#5
(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 ?  Big Grin

Yeah that's right. Smile "rompe-ladrillo del mundo"

(03-18-2024, 06:19 PM)Marcus Wrote: Very nice, very retro Smile

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
The translator translates in his own way. Sad

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. Confused
Reply
#6
Hitting the brick two or three times is "too easy"? lol Nah... I knew what you meant.

As Marcus has already said, "Very retro"! Cool...
Logic is the beginning of wisdom.
Reply
#7
(03-18-2024, 10:22 PM)johnno56 Wrote: Hitting the brick two or three times is "too easy"? lol  Nah... I knew what you meant.

As Marcus has already said, "Very retro"! Cool...

Arkanoid - Level 3 
Please don't try this at home  Cool

   
click the image to see the animated gif of Level 3
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)