After getting lost myself in project too big for the beginner I am, I decided to go for a simpler project: a Breakout/Arkanoid clone. After doing the the engine in a few hours, I couldn't help myself and had to make an editor that took me days and days to complete. Anyway, first, some stuff for the eyes:
The title/main screen:
Some gameplay:
The editor:
And a video of the 3 first levels (yes they are complete rip-off Arkanoid):
The game is playable and the 30 levels can be completed (at least in easy mode). There are still a lot of bugs around, please don't press any key during result screen.
But my main problem is that the "physics" is not really working the way I want it to be. I use Hardon Collider for collision management. And I think my problem comes from a misunderstanding of the library.
The global idea is that only the paddle is able to fully change the angle of the ball. Hitting the walls or a brick will mirror the angle. The problem is that often the ball will go through some bricks...
Here is the code I use to change the angle of the ball when it hit a brick, where dx and dy are the displacement vectors provided by Hardon Collider, b is the ball and x and y are the center of the 64*32 pixels brick:
Code: Select all
if y < b.y then -- ball is under the brick.
if b.x - x >= 32 then --ball is on the right
b.angle = 180 - b.angle
b.x = b.x + dx
b.y = b.y + dy
elseif b.x - x <= -32 then --ball is on the left
b.angle = 180 - b.angle
b.x = b.x - dx
b.y = b.y + dy
else --ball is fully under
b.angle = 0 - b.angle
b.y = b.y + dy
end
else -- ball is over the brick
if b.x - x >= 32 then --ball is on the right
b.angle = 180 - b.angle
b.x = b.x + dx
b.y = b.y - dy
elseif b.x - x <= -32 then --ball is on the left
b.angle = 180 - b.angle
b.x = b.x - dx
b.y = b.y - dy
else --ball is fully over
b.angle = 0 - b.angle
b.y = b.y - dy
end
end