Arkanoid part 6 – Still on bricks collision

Arkanoid made with pygame, part 6.

Now it collides up and down, but in a strange way when it hits the middle of a brick (the ball goes inside the brick, because it goes both up and down util it collides with the brick, so it moves horizzontally for the lenght of the brick).

I just added a couple of lines in the collision function

Another small change: a function to show the bricks

In the while loop now there is this function call

and the function is simply this (nothing changed in the showing of the bricks)

How the list of bricks is made

I memorize into this the bricks sprites

that calls this function that returns the list

h = 30 is the vertical position of the first line of the bricks.

As you see in h += 50, the other lines of bricks are now 50 pixels distant from each other. I also added another line of bricks that now are also more distant horizzontally and there are just 5 bricks for line.

The bricks are built on this class:

As you can see there is the self.rect attribute that contains a Rect object with the position of each brick. Being them listed in the bricks list the collision is detected in the function collision like this (as I showed before)


The whole code

1.1 – Pong the father of Arkanoid

Pong v. 1.0 – Pygame example

1.2 – Starting arkanoid… from pong

Arkanoid… let’s make it better…

1.3 – Adding background

ArkaPyGame 1.3 – Adding a background

1.4 – Collision detection

ArkaPygame 1.4 – Collision detected

1.5 – Bricks collisions

Arkanoid in pygame part 5

1.6 – Still on Collisions

Arkanoid part 6 – Still on bricks collision

1.7 – Fixed strange bouncing

Arkanoid 1.7 – Fixed strange bouncing

1.8 – How to destroy the bricks

Arkanoid 1.8 – First stage almost complete: destroy bricks

1.9 – More levels

Arkanoid 1.9 – more stages

2.1 – Infinite level generator

Arkanoid 2.0 – infinite levels

2.3 – Sounds and faster frame rate tecnique

ArkaPyGame 2.1 – Arkanoid like game made with Pygame

2.5 – New nicer levels simmetric and in color and menus

Arkanoid-Pygame 2.5 – New levels and menu

2.6 – Keyboard control

ArkaGame 2.6 – Adding keyboard commands

2.7 – Mouse exclusive control

Arkanoid 2.7 with Pygame – Mouse control – Tiny version

TinyArka – “Mini” version of Arkanoid with pygame

5.0 – Arkagame: 5 different versions

Breakout / Arkanoid – 5 versions in one (pygame)

Github repository

Pygame map editor devlog

The devlog of the Pygame map editor. A work in progress to create a map editor to create maps with tiles with an example of a game that uses these maps. The current version is 1.5 of the map editor and 0.2 of the game, not yet ready for the 1.5 version of the editor (16.9.2020). Repository of the map editor