Worklog for RemiD - breakout 2D arcade game


Attention! 👉Starting November 2024, BlitzCoder.org will now be BlitzBasic.org.

 

Tweet 2d worklogs
RemiD

hi,

it is the winter months again here (France), so i have decided to work on an arcade game : breakout 2D.

i am going to post my progress here, and to post some code examples (blitzbasic) of things that i need to make the game.

first look of the layout of the game :
http://rd-stuff.fr/blitz3d/breakout-2D-20221122-2340.png

cheers,

just to show the last update on this breakout 2d game (2023.01.05) :
http://rd-stuff.fr/blitz3d/breakout-2d-wip-20230105-1210.png

the idea was to have small blocks cover an image, and use the ball to destroy the blocks and reveal the image, and not have the ball touch the borders (using the 4 bouncers).
each time the ball touches a border it damages the ball and adds a new block to re-cover the image. 
a breakout-like gameplay...

with several powerups: 
-multi balls
-ball goes through blocks
-ball shoots bullets
-ball triggers an explosion
-ball magnet effect (attracts the near blocks)

for the images in the background, i wanted to have simple drawings made using my tablet + pen, or maybe generated procedurally using meshes (parts), with images corresponding to a specific theme. (in this case 'old school summer babes')

maybe i will finish it someday...

anyway this was interesting to code a game (prototype) only with 2d maths and 2d graphics. 

i am still working on this but i am experimenting with different gameplay mechanics before posting more...

there was a nasty bug, never found the cause... :(

so i had to rewrite the code for the direction+movement and detection of collisions and repositionning, and now it works well. :)

i have reduced the size of the blocks so that they can be created and positionned depending on the colored pixels of a background image.

http://rd-stuff.fr/blitz3d/breakout-2d-wip-20221217-1152.png

for this game i use several lists for entities (walls, bouncers, blocks, balls) (in arrays), and one list for colliders (in arrays).

i also use a few others lists (custom types) for things which are automatically destroyed (like impacts and parts).

and sometimes i have to delete one entity (a destroyed block or a lost ball) and the corresponding collider.

and i need to have a link between the entity and the collider and a link between the collider and the entity.

the problem is to reorganize the entities list and the colliders list without making errors.

so i thought about how to do it the best way...

and then i did a simple test : how much time would it take to recreate all colliders ?
answer : 0.007 millisecond to recreate all colliders (which are only x, y coordinates of centers and of starts and ends of lines)

all this to say that sometimes there is no need to find the most optimized solution !

problem solved !

i think that i am going to have 4 'bouncers', one for each side of the screen, all controlled using the mouse x axis and y axis,
and small blocks at the center of the screen, which cover some parts of an image.

and the goal will be to break all blocks to reveal the image, without losing the ball.

a later feature would be to generate random images, for never ending games.

wrong post...

some progress :
finally my 2d orientation + movement + collision system works well
after a lot of experiments and debugging

http://rd-stuff.fr/blitz3d/wip-breakout-2d-20221208-2251.png

on this screenshot, we can see the colliders of the walls, of the blocks, of the bouncer, of the ball.

the colliders out of range (too far from the ball) are in grey, the colliders in range (near enough the ball) are in white, the dots represents the centers of each collider.

the yellow line represents the movement vector of the ball (direction normal * speed).

the blue line represents the nearest line intersected by the movement vector.

the magenta line represents the collision normal (of the nearest intersected line).

the cyan line represents the reflection normal (the ball orientation after the collision).

good !

next step : ?