simple arkanoid clone in Love2d (+tutorial)

simple arkanoid clone in Love2d (+tutorial)

Postby noway » 20 Apr 2017, 17:12

Hey!

I have been writing a simple Arkanoid-type game with LÖVE framework, but at some point I've decided to turn it into a tutorial.

Here is a couple of screenshots:
Image Image
Image Image

My current plans are to finish the tutorial about programming part and then to update the graphics and the sound.
In the end, I want to achieve a small (~20 levels or so) but well-polished game.

LÖVE framework uses Lua language and it is geared towards 2d games.
It is cross-platform, running on major desktop and mobile operating systems, and on the web (with the help of external tools).
Here is a couple of example games: Mari0, Mr. Rescue.
Last, but not least, it is free and open-source.
LÖVE is simple and intuitive; glancing over this short article is enough to understand it's basic principles of operation.

The tutorial is intended for people, who have basic programming experience, but have trouble structuring their code for projects bigger than "Hello World". An Arkanoid, while simple, contains many elements found in more elaborate games. My aim is to introduce a typical code structure, and to provide a starting point for further modifications.

Chapter 1 describes how to build a prototype for an Arkanoid-type game in the most straightforward way,
without relying too much on any external libraries or advanced language features.

(follow the links for the screenshots).
1. The Ball, The Brick, The Platform
2. Bricks and Walls
3. Detecting Collisions
4. Resolving Collisions
5. Levels

Chapter 2 expands the prototype, introducing gamestates, basic graphics and sound.
At the end of this chapter, the general frame of the game is complete. What is left
is to fill it with the details.

1. Splitting Code into Several Files
2. Loading Levels from Files
3. Straightforward Gamestates
4. Advanced Gamestates
5. Basic Tiles
6. Different Brick Types
7. Basic Sound
8. Game Over

Chapter 3 proceeds to add functionality to achieve a full-featured game.
While the code for this chapter works and available in the repository, some minor corrections are required.
Overall, this chapter is currently in a draft stage.

1. Better Ball Rebounds
2. Ball Launch From Platform (Two Objects Moving Together)
3. Mouse Controls
4. Spawning Bonuses
5. Bonus Effects
6. Glue Bonus
7. Add New Ball Bonus (draft)
8. Life and Next Level Bonuses (draft)
9. Random Bonuses (draft)
10. Menu Buttons (draft)
11. Wall Tiles (draft)
12. Side Panel (draft)
13. Score (draft)
14. Fonts (draft)
15. More Sounds (draft)
16. Final Screen (draft)
17. Packaging and Distribution (draft)

Any feedback is appreciated.
noway
 
Posts: 7
Joined: 20 Apr 2017, 16:56

Re: simple arkanoid clone in Love2d (+tutorial)

Postby Lyberta » 21 Apr 2017, 15:37

So it uses global variables everywhere?

Are there any multiplayer games made with love2d?
Some crazy person on the Internet.
User avatar
Lyberta
 
Posts: 291
Joined: 19 Jun 2013, 10:45

Re: simple arkanoid clone in Love2d (+tutorial)

Postby noway » 22 Apr 2017, 07:36

So it uses global variables everywhere?

I'm not sure what do you mean by that.

For each game object, a separate table is created to hold it's properties.
In the first chapter the whole code is contained in a single file and the tables representing objects are effectively in the global scope.
In the second chapter, the code is split into several files and the game states are introduced.
Each game state loads only those objects, that are necessary for it's working, so the code structure becomes more standard.

Are there any multiplayer games made with love2d?

Yes, Boss Bashing Button Brawlers for example.
A networking tutorial can be found on the Love wiki.

Btw, there are more games on itch, that use Love2d as the engine.
noway
 
Posts: 7
Joined: 20 Apr 2017, 16:56

Re: simple arkanoid clone in Love2d (+tutorial)

Postby Lyberta » 22 Apr 2017, 16:55

noway {l Wrote}:
So it uses global variables everywhere?

I'm not sure what do you mean by that.

For each game object, a separate table is created to hold it's properties.
In the first chapter the whole code is contained in a single file and the tables representing objects are effectively in the global scope.
In the second chapter, the code is split into several files and the game states are introduced.
Each game state loads only those objects, that are necessary for it's working, so the code structure becomes more standard.


Well, in this case I mean variables that are visible globally and on the file scope. I know Lua is not meant for a serious work, I just try to avoid global variables.

noway {l Wrote}:Yes, Boss Bashing Button Brawlers for example.
A networking tutorial can be found on the Love wiki.


Oh, they use text strings, I see. I'd expect some sort of serialization library where you simply define fields that are replicated automatically.
Some crazy person on the Internet.
User avatar
Lyberta
 
Posts: 291
Joined: 19 Jun 2013, 10:45

Re: simple arkanoid clone in Love2d (+tutorial)

Postby noway » 23 Apr 2017, 17:11

Well, in this case I mean variables that are visible globally and on the file scope. I know Lua is not meant for a serious work, I just try to avoid global variables.

You can think of `main.lua` as being equivalent to `main` function in other languages.
That way, variables with file scope in the `main.lua` are equivalent to variables local to `main` function.
If your `main` function consists of several sub-procedures, such as `initialize`, `game_loop` and `finalize`, typically you need
to declare some variables in the scope of the `main` function to pass the game objects between these sub-procedures.

If you do not like such an approach, you can define your own game loop and declare all the variables local to it.

Oh, they use text strings, I see. I'd expect some sort of serialization library where you simply define fields that are replicated automatically.

There are several networking libraries listed on the wiki. They provide some abstraction over basic networking facilities.
noway
 
Posts: 7
Joined: 20 Apr 2017, 16:56

Re: simple arkanoid clone in Love2d (+tutorial)

Postby noway » 21 May 2017, 13:58

Several parts on the wiki have been updated: Add New Ball Bonus , Life and Next Level Bonuses, and Random bonus generation.
The first appendix - Storing Levels as Strings - has been added.

Image Image
noway
 
Posts: 7
Joined: 20 Apr 2017, 16:56

Re: simple arkanoid clone in Love2d (+tutorial)

Postby noway » 28 May 2017, 06:34

Two more updates: simple main menu and wall tiles.

Image Image
noway
 
Posts: 7
Joined: 20 Apr 2017, 16:56

Re: simple arkanoid clone in Love2d (+tutorial)

Postby noway » 06 Jun 2017, 15:45

Several updates in the wiki: Side Panel, Score, Fonts, More Sounds

Image Image
noway
 
Posts: 7
Joined: 20 Apr 2017, 16:56

Re: simple arkanoid clone in Love2d (+tutorial)

Postby noway » 02 Jul 2017, 08:50

've finished the last 2 parts of the tutorial: credits screen and packaging.

Image

All in all I don't like how the Chapter 3 has turned out.
My initial idea has been to discuss typical problems arising in game programming on real-life examples.
However, most of the code in Chapter 3 has become too specific for this Arkanoid and hardly can be transferred to any other project.
Besides, technical details of the specific implementation obscure the general ideas.
I think, instead of describing a step by step code evolution, a better approach would be to restructure the Chapter 3 into a series of loosely related articles grouped by a common subject. For example, a group on visual effects with articles on postprocessing, particle effects, etc. Basically, topics currently placed in appendicies should become the main material for this chapter.

This will require a lot of work that I currently don't want to deal with.
Instead I would like to concentrate on making a small but well-polished, publishable quality, game.
As one of the first steps, this will require to find an artist and a sound designer.

Regarding the tutorial, the plan is following:
1) Update the Chapters 1 and 2.
2) Find a native speaker to get help with the text proofreading.
3) Restructure the Chapter 3 into a series of "additional topics".
noway
 
Posts: 7
Joined: 20 Apr 2017, 16:56

Who is online

Users browsing this forum: No registered users and 1 guest