Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [SFML2.1] Pong, Snake, Arkanoid, Tetris and Pacman games  (Read 25666 times)

0 Members and 1 Guest are viewing this topic.

JuDelCo

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
    • JuDelCo's Twitter
[SFML2.1] Pong, Snake, Arkanoid, Tetris and Pacman games
« on: September 12, 2013, 10:55:42 pm »
First off, I made these games with objetive of learn how to make games (because I never finished one, I'm always reading docs and things but I never convinced to finish a project, so I decided to make a serie of games from the very basics to others more complicated. These games were done in a few hours each one (except Pacman, because it's more complicated) with the simplicity idea in mind (remember, the purpose was to finish them, not make it cool or perfect but functional and bugfree).

All of these games are built with SFML 2.1 + GCC (MinGW for windows). The base code is the same for all games (its the reason all games are located in "Game/" folder and all code base is in "Engine/". The engine was very bad designed and lacks of everything. This is because I made it before the games (Guys, DON'T make a "engine" if you don't know which will be your game requisites exactly, in other words, don't make it if you didn't finished a few games before so you will know exactly what you'll need).

So let's begin:

---------------------------------------------------------------------------------------

Pong



Download (Win x86): http://www.mediafire.com/download/aidxwov5tnirz39/Pong.rar
Source: https://github.com/JuDelCo/SFML2-Game

Controls:
  • Arrows: Movement
  • F1: Reset
  • Escape: Exit game


Snake



Download (Win x86): http://www.mediafire.com/download/yawhlmagt29nvab/Snake.rar
Source: https://github.com/JuDelCo/SFML2-Game

Controls:
  • Arrows: Movement
  • F1: Reset
  • Escape: Exit game


Arkanoid



Download (Win x86): http://www.mediafire.com/download/vb44w8bu4o8g7nw/Arkanoid.rar
Source: https://github.com/JuDelCo/SFML2-Game

Controls:
  • Arrows: Movement
  • F1: Reset
  • F2: Mute/Unmute SFX
  • Escape: Exit game


Tetris



Download (Win x86): http://www.mediafire.com/download/1nbp31bbkatzie2/Tetris.rar
Source: https://github.com/JuDelCo/SFML2-Game

Controls:
  • Arrows: Movement
  • Space: Rotation
  • F1: Reset
  • F2: Mute/Unmute SFX
  • F3: Switch Modes (Normal / Hard)
  • Escape: Exit game
Note: Hard mode it's the same as Normal but sometimes will appear some pieces with crazy shapes (they will difficult your way to make lines)


Pacman:



Download (Win x86): http://www.mediafire.com/download/tu227yts56au21j/Pacman_1.0.1.rar
Source: https://github.com/JuDelCo/SFML2-Game

Controls:
  • Arrows: Movement
  • F1: Reset
  • F2: Mute/Unmute SFX
  • Escape: Exit game

The map editor in HTML/JS (yes, you can change or make your own maps) was made by Elendow

Bonus! (Wallpaper 1920x1080): Download / Open in Web Navigator

---------------------------------------------------------------------------------------


I don't know which kind of game do now... maybe a shoot'em up or simple platform game... but first i need to change a lot of things in the """engine"""... (it's more like a messy chunk of code lol xD)

Feedback will be always welcome  ^_^

Happy Coding!  :P


---
JuDelCo

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: [SFML2.1] Pong, Snake, Arkanoid, Tetris and Pacman games
« Reply #1 on: September 12, 2013, 11:30:32 pm »
I had almost exactly the same idea(mine was: make few minigames and turn them into smallish engine) but didn't follow up on it and stopped at adapting my Pacman clone to have scripted AI and have more consistent code. Nice that you came through and did all these minigames.
Quote
Guys, DON'T make a "engine" if you don't know which will be your game requisites exactly, in other words, don't make it if you didn't finished a few games before so you will know exactly what you'll need
Yeah, I agree very much.
« Last Edit: September 12, 2013, 11:33:04 pm by FRex »
Back to C++ gamedev with SFML in May 2023

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: [SFML2.1] Pong, Snake, Arkanoid, Tetris and Pacman games
« Reply #2 on: September 12, 2013, 11:42:48 pm »
Nicely done! Not many have achieve what you just did (I guess including me :P)!

Guys, DON'T make a "engine" if you don't know which will be your game requisites exactly, in other words, don't make it if you didn't finished a few games before so you will know exactly what you'll need
Some true words here! "Write Games, Not Engines!" :)

I've quickly gone through all the games and here's my feedback:

Pong
Is it just me or can the AI move its paddle faster than the player can?

Snake
Key input seems to be handle oddly, at least it's impossible to do two direction changes very quickly one after the other, which kind of kills the whole Snake game play. Also the sound for moving gets totally annoying and  the movement speed could be faster.

Arkanoid
Interesting that you didn't choose "Breakout" as name, since Arkanoid was based on the Atari Breakout and I believe it was more popular.
For playing it seems like the paddle should be able to move faster.

Tetris
A more standard binding of the keys would be:
Arrow Left to move left
Arrow Right to move right
Arrow Up to rotate the pieces
Arrow Down to move the pieces down
Space to set the piece fully down.

I especially missed the option to directly place a block.
There also seems to be a bug. Even though I've filled 4 lines at once, it only removed 2 lines.

Pacman
It seems like the ghosts get somehow a bit stuck in the spawning location. Also looking at some original game play of Pacman it seems like all the ghost on the screen turn when eating the bigger coin, even the ones that are still in the spawning area.

As for the code, I've really only taken a glimpse and saw some manual memory management. With modern C++ in mind and some C++11 features at hand, it's really not needed to manually manage the memory, as you can see in recent talk (jump to minute 20) of the creator of C++ Bjarne Stroustrup.
If you watch the linked video above you'll can also take away the points of passing around data. I've seen the use of some raw pointers, which most likely is not justified or stuff like const int& which doesn't make sense and should rather be passed as an actual integer itself.
Other than that on the surface, which is what I've looked at, the code seems a lot better than many code examples I've seen in the past here on the forum. ;)

I've added it to the huge list of new topics for the next SFML News.
« Last Edit: September 12, 2013, 11:44:59 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

JuDelCo

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
    • JuDelCo's Twitter
Re: [SFML2.1] Pong, Snake, Arkanoid, Tetris and Pacman games
« Reply #3 on: September 13, 2013, 10:41:35 pm »
Pong
Is it just me or can the AI move its paddle faster than the player can?

Maybe, I never cared the quality of this game. The main reason of the game was to "warmup" for the others and setup all the IDE and compiler/linker to work for the next ones xD

Snake
Key input seems to be handle oddly, at least it's impossible to do two direction changes very quickly one after the other, which kind of kills the whole Snake game play. Also the sound for moving gets totally annoying and  the movement speed could be faster.

Except for the fact you can turn your direction to the back of the head (so you instant lose because it collides with the body) I think the control is just I wanted... mmm

Speed faster... next time  :P

Arkanoid
Interesting that you didn't choose "Breakout" as name, since Arkanoid was based on the Atari Breakout and I believe it was more popular.
For playing it seems like the paddle should be able to move faster.

Oh, that's interesting. Here in Spain (english is NOT my native language, sorry if I misspell a phrase or word...) this game is know as "Arkanoid" rather than Breakout. I didn't know this game was based on it.

And yes, paddle faster... but I wanted to test well the collisions of the ball with it so I made it slower (sorry for the slooow gameplay then xD)

Tetris
A more standard binding of the keys would be:
Arrow Left to move left
Arrow Right to move right
Arrow Up to rotate the pieces
Arrow Down to move the pieces down
Space to set the piece fully down.

I especially missed the option to directly place a block.
There also seems to be a bug. Even though I've filled 4 lines at once, it only removed 2 lines.

Honestly, all these games are done from my memory so like this case, it's very normal to fail my approach to "clone" the original game exactly. I didn't know the original binding of the keys so I just keep with the same of the previous games (snake and pong).

I played a bit before "release" it and didn't find that bug.... I'm very surprised.

Pacman
It seems like the ghosts get somehow a bit stuck in the spawning location. Also looking at some original game play of Pacman it seems like all the ghost on the screen turn when eating the bigger coin, even the ones that are still in the spawning area.

You can make changes to the map and define the ghost's "houses" in any point of the map (they can spawn in any place, they don't need to be closed by a "ghost door" or something. You can put only 1 ghost too (up to 4). The requisites of the map is 1 ghost minimum, a pacman spawn location and one ball (the type doesn't matter).

Like I said before, I only copied pacman in the map, the gameplay was from my memory too so again, it's possible it doesn't fit exactly to the original xD

As for the code, I've really only taken a glimpse and saw some manual memory management. With modern C++ in mind and some C++11 features at hand, it's really not needed to manually manage the memory, as you can see in recent talk (jump to minute 20) of the creator of C++ Bjarne Stroustrup.
If you watch the linked video above you'll can also take away the points of passing around data. I've seen the use of some raw pointers, which most likely is not justified or stuff like const int& which doesn't make sense and should rather be passed as an actual integer itself.
Other than that on the surface, which is what I've looked at, the code seems a lot better than many code examples I've seen in the past here on the forum. ;)

Yes, the code is C++11 but don't everything (more like some things only xD). I need to switch my pointers to use smart pointers. I know how to use them so no problem with that, but sometimes it's more easy and quick for me to use classical pointers. The code inside "Engine/" folder it's very old and it's mainly a bunch of chuncks of code from older (some VERY old) projects of mine and from other opensource projects "glued" together. I need to rewrite some things, add others and delete more to polish this code...

About the talk, I'll see it tomorrow ^^  Thanks

I've added it to the huge list of new topics for the next SFML News.

Ok!  ;D



PS: All the changes suggested are a good start point for other people who wants to download the source and make changes so they can "learn" from a game already programmed... I just want to skip to the next one