One more arkanoid clone

Show off your games, demos and other (playable) creations.
Post Reply
noway
Prole
Posts: 43
Joined: Mon Mar 21, 2011 7:58 am

One more arkanoid clone

Post by noway »

Hello.

I'm writing an arkanoid (breakout)-type game, and it is mostly in a playable state (see attachment).
However, there are some problems with code and art, and I would like to ask some help regarding them.

1) I'm using HardonCollider to detect collisions.
At high speed the ball sometimes passes through blocks, walls, or the platform.
What can be done to fix such behaviour?

2) On my machine the game sometimes noticeablay lags.
I've tried to adjust cellsize in spatialhash of HC, but I'm sure this is not a sole reason for low performance.
I would appreciate any advice on how to improve performance and make the game run more smoothly.

3) I'm planning to write a tutorial, describing the whole development process.
First few parts are available on github.
The code is finished, but the explanatory text is not in a readable form yet.
The general plan is approximately following:
1. The Ball, The Brick, The Platform
2. Modules
3. Classes
4. Container Classes
5. Detecting Collisions
6. Resolving Collisions
7. Loading Level From External File
8. Changing Levels
9. Basic Gamestates: Game and Menu
10. More Gamestates: Gamepaused and Gamefinished
11. Tiles
12. Bonuses
13. Menu Buttons
14. Scores and Lives and Fonts
15. Sound
16. Animation
17. Finishing Touches
18. Packaging and Distribution

I would appreciate any ideas, suggestions, improvements or just any other feedback you have.
I think, after I rewrite the text into readable form, I'll start a separate forum thread dedicated to this material.

4) I'm open for collaboration.
Help with graphics and sound is desperately wanted.
Ideas on level design and final screen also would be useful.
A goal is to make a decently polished, though simple game, that can serve for educational purposes.
If volunteering work is against your principles, compensation is negotiable.
( But don't expect much more than a couple of beers, since it is a hobby and non-for-profit project ).
Attachments
arcanoid.love
(626.95 KiB) Downloaded 173 times
Germanunkol
Party member
Posts: 712
Joined: Fri Jun 22, 2012 4:54 pm
Contact:

Re: One more arkanoid clone

Post by Germanunkol »

Hey, cool, I've always liked arcanoid (especially the ones with cool power-ups)!

To 1): If you really want to stick to HardonCollider, can you maybe make multiple updates per frame? I hear physics-engines sometimes do that.
If not, programming your own physics for a game like this should be simple enough. Since Physics libraries often only calculate "is the shape inside another shape" to detect a hit, they won't detect collisions if the ball is in front of the object in one frame and fully behind it in the next. I'm guessing that's how HardonCollider works as well. If you want to program this yourself, you can simply check the full line of movement (calculate whether the line of movement which the ball is to make this frame intersects with any boxes). Of course, you'll actually need to calcuate two lines (the center line, offset by the radius) to make up for the width of the ball.
This would be the most fun way to solve your the problem, but definitely not the quickest...
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
noway
Prole
Posts: 43
Joined: Mon Mar 21, 2011 7:58 am

Re: One more arkanoid clone

Post by noway »

Thanks for suggestions.
Since Physics libraries often only calculate "is the shape inside another shape" to detect a hit, they won't detect collisions if the ball is in front of the object in one frame and fully behind it in the next. I'm guessing that's how HardonCollider works as well.
Indeed, it works like that. It doesn't have any notion of speed of shapes. Maybe HC just isn't an optimal choice for a high-paced game.
1): If you really want to stick to HardonCollider, can you maybe make multiple updates per frame? I hear physics-engines sometimes do that.
That can be done, but obviously that would just increase an upper limit for the ball's speed.
On the other hand, it could be enough for practical purposes.
I'll test this idea.
If you want to program this yourself, you can simply check the full line of movement (calculate whether the line of movement which the ball is to make this frame intersects with any boxes). Of course, you'll actually need to calcuate two lines (the center line, offset by the radius) to make up for the width of the ball.
This would be the most fun way to solve your the problem, but definitely not the quickest...
I think I'll first try to use 'several-updates-per-frame' method. If that doesn't work, than it would be necessary to code collision detection manually.
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: One more arkanoid clone

Post by zorg »

noway wrote:
Since Physics libraries often only calculate "is the shape inside another shape" to detect a hit, they won't detect collisions if the ball is in front of the object in one frame and fully behind it in the next. I'm guessing that's how HardonCollider works as well.
Indeed, it works like that. It doesn't have any notion of speed of shapes. Maybe HC just isn't an optimal choice for a high-paced game.
If i remember correctly, HC indeed doesn't do "tunneling", but kikito's bump does.... however, that can only handle Axis-aligned bounding boxes, so no circles or arbitrary polygons.
Since in arkanoid, the ball technically doesn't rotate, you could treat it as an AABB from a collision perspective, so bump may work out for you better than HC.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
noway
Prole
Posts: 43
Joined: Mon Mar 21, 2011 7:58 am

Re: One more arkanoid clone

Post by noway »

If i remember correctly, HC indeed doesn't do "tunneling", but kikito's bump does.... however, that can only handle Axis-aligned bounding boxes, so no circles or arbitrary polygons.
Since in arkanoid, the ball technically doesn't rotate, you could treat it as an AABB from a collision perspective, so bump may work out for you better than HC.
Ok, thanks. I'll take a look at it.
noway
Prole
Posts: 43
Joined: Mon Mar 21, 2011 7:58 am

Re: One more arkanoid clone

Post by noway »

Hey!

I've updated the code a bit: added music, sounds, a gameover condition, and several new levels.
Also I've drafted several new sections in the accompanying tutorial.

Here is the new contents:

1. [The Ball, The Brick, The Platform](https://github.com/noooway/love2d_arkan ... e-Platform)
2. [Splitting Code into Several Files (Lua Modules)](https://github.com/noooway/love2d_arkan ... /2-Modules)
3. [Classes](https://github.com/noooway/love2d_arkan ... /3-Classes)
4. [Other Bricks and The Walls (Container Classes)](https://github.com/noooway/love2d_arkan ... er-Classes)
5. [Detecting Collisions](https://github.com/noooway/love2d_arkan ... Collisions)
6. [Resolving Collisions](https://github.com/noooway/love2d_arkan ... Collisions)
7. [Loading Level From External File](https://github.com/noooway/love2d_arkan ... ernal-File)
8. [Changing Levels](https://github.com/noooway/love2d_arkan ... ing-Levels)
9. [Basic Gamestates: Game and Menu](https://github.com/noooway/love2d_arkan ... e-and-Menu)
10. [More Gamestates: Gamepaused and Gamefinished](https://github.com/noooway/love2d_arkan ... mefinished)
11. [Basic Tiles](https://github.com/noooway/love2d_arkan ... asic-Tiles)
12. [Different Brick Types](https://github.com/noooway/love2d_arkan ... rick-Types)
13. [Spawning Bonuses](https://github.com/noooway/love2d_arkan ... ng-Bonuses)
14. [Bonus Effects](https://github.com/noooway/love2d_arkan ... us-effects)
15. [Details: Add-New-Ball Bonus](https://github.com/noooway/love2d_arkan ... Ball-Bonus)
16. [Ball Launch From Platform (Two Objects Moving Together)](https://github.com/noooway/love2d_arkan ... ogether%29)
17. [Details: Better Ball Rebounds](https://github.com/noooway/love2d_arkan ... l-Rebounds)
18. [Details: Glue Bonus](https://github.com/noooway/love2d_arkan ... Glue-Bonus)
19. [Menu Buttons](https://github.com/noooway/love2d_arkan ... nu-Buttons)
20. [Lives and Score](https://github.com/noooway/love2d_arkan ... -and-Score)
21. [Wall Tiles](https://github.com/noooway/love2d_arkan ... Wall-Tiles)
22. [Side Panel Background](https://github.com/noooway/love2d_arkan ... Background)
23. [Fonts in Lives and Score](https://github.com/noooway/love2d_arkan ... -and-Score)
24. [Mouse Controls](https://github.com/noooway/love2d_arkan ... e-Controls)
25. [Details: Random Bonuses](https://github.com/noooway/love2d_arkan ... om-Bonuses)
26. [Sound](https://github.com/noooway/love2d_arkan ... wiki/Sound)
27. [Final Screen](https://github.com/noooway/love2d_arkan ... nal-Screen)
28. [Game Over](https://github.com/noooway/love2d_arkan ... /Game-Over)
29. [Packaging and Distribution](https://github.com/noooway/love2d_arkan ... stribution)


Edit: updated the game to work with love 0.10.*
Attachments
love2d_arkanoid_tutorial.love
(2.71 MiB) Downloaded 82 times
Post Reply

Who is online

Users browsing this forum: No registered users and 49 guests