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

Author Topic: My Practice Beginner Games  (Read 18518 times)

0 Members and 1 Guest are viewing this topic.

Hapax

  • Hero Member
  • *****
  • Posts: 3346
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
My Practice Beginner Games
« on: August 23, 2015, 08:47:23 pm »
Foreword
I realised that I have avoided programming those beginner games that everyone does to learn stuff and for general practice so I decided that I'm going to finally attempt them.

This project (of multiple games) doubles as practice for using GitHub too so it will all be available on GitHub. The repositories are the actual files that I am working on so you so you will be able to see my workings, mistakes, and re-factoring (I tend to do that a lot, I think). This also means that you can feel free to raise issues on the repository and the like.

Of course, SFML will be the base library for all games. Who actually wants to write console-only games?  :P
I also will be using a few small libraries of my own - all of which are completely available on GitHub.

I'll be up for discussions on any part of the project - including suggestions - but not really questions about C++ that should be, at the very least, first googled.

Games
Complete:
Current Work In Progress:

Early video of MTD (v0.0.2):
http://youtu.be/K5IZUl_7BaY

Video of Puzza (v1.0.0):
http://youtu.be/Hp1IyuBLyRE

(click to show/hide)

The Code
Click here to visit the GitHub repository.

Disclaimer
These "games" are work(s) in progress and no guarantees to their working success are given.
I may or may not decide to work on more than one game at a time.
None of this can be considered tutoring. It is not intended to teach. I am learning and this is what I am doing. That is all.
« Last Edit: February 11, 2016, 09:40:33 pm by Hapax »
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

SeriousITGuy

  • Full Member
  • ***
  • Posts: 123
  • Still learning...
    • View Profile
Re: My Practice Beginner Games
« Reply #1 on: August 27, 2015, 09:39:33 am »
Hey Hapax,

same thing here. I was working on my RPG for the last year and I also did not tackle "the practice games" ;)
Didn't finish anything before, so I started going back to the basics three weeks ago and guess what, my Pong clone comes along nicely with all the things I learned the last year. And it is a great project for getting 2D-vector math straight, atm I work on a mathematically and physically correct colision and reflection logic for the game ball.
I'll look on your code, maybe there is something to learn also ;) Oh and btw, why do you use an 8-space wide tab? It makes code anoying to read, I work with two whitespace tabs.

Keep on! ;)

Edit: something to stay entertained while coding Pong https://www.youtube.com/watch?v=cNAdtkSjSps ;)
« Last Edit: August 27, 2015, 10:21:11 am by SeriousITGuy »

Hapax

  • Hero Member
  • *****
  • Posts: 3346
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: My Practice Beginner Games
« Reply #2 on: August 27, 2015, 01:06:47 pm »
Hi!

Thanks for the comments. They are always appreciated.  :)

I don't think I'm going to be implementing physically accurate ball collision. It's only pong :P
However, I do have something slightly different planned to make it more interesting  ;)

Haha at the Pong song. I've seen it before though. Hehe

Oh and btw, why do you use an 8-space wide tab? It makes code anoying to read, I work with two whitespace tabs.
I don't; I use 4-space wide tabs but they're still tabs so GitHub displays them as 8 spaces.
You can add ?ts=4 (my original layout) or ?ts=2 (your preference) to the end of the URL in GitHub to change its tab size.
e.g.
https://github.com/Hapaxia/MyPracticeBeginnerGames/blob/master/Puzza/main.cpp?ts=4

Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Hapax

  • Hero Member
  • *****
  • Posts: 3346
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: My Practice Beginner Games
« Reply #3 on: August 27, 2015, 02:25:17 pm »
Added a Windows build of its current state to a GitHub release.

Feel free to try it if you can (via the build or the code). I always appreciate feedback  :)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

SeriousITGuy

  • Full Member
  • ***
  • Posts: 123
  • Still learning...
    • View Profile
Re: My Practice Beginner Games
« Reply #4 on: August 28, 2015, 08:54:52 am »
Oh I did not know about the tab space feature of github, now it is better ;)

Tested your release, mouse movement is interesting especially with acceleration, plays nice. Stoping/Reseting the ball manually is a nice feature for debugging, I will integrate this also ;)
Maybe I can do an upload today.

Cheers!

Hapax

  • Hero Member
  • *****
  • Posts: 3346
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: My Practice Beginner Games
« Reply #5 on: August 28, 2015, 02:24:10 pm »
It's a shame that you can't set an account preference in GitHub for displaying tabs.

I generally add so loads of control over things during development (not that I finish many things and remove them!); F12 in Puzza is a forced exception  ;D

Did you notice that you can control the ball with the arrow keys?  ;)

If you can build from source (which may or may not be possible as my libraries don't work for everyone), you could try the add-spin-to-ball branch. Guess what that does  ;)

I keep tweaking the paddle control. The player paddle in the latest version is much more responsive but the acceleration etc. is useful for 'dumbing down' the AI.

Thanks again for taking the time to try it and for the feedback. I look forward to testing yours  ;)

p.s. If the smileys in this post are anything to go by, I must have something in my eye...
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

SeriousITGuy

  • Full Member
  • ***
  • Posts: 123
  • Still learning...
    • View Profile
Re: My Practice Beginner Games
« Reply #6 on: August 28, 2015, 03:01:17 pm »
If Diablo 3 Season 4 Start nets some free time this weekend I try to build it myself and see your interesting branch. And yes I noticed the arrow keys as I started using them to control the paddle before realizing I need the mouse to do that  :D

I threw together a first playable version of mine https://github.com/SeriousITGuy/SFML-Pong
Should compile without problems, you only need to set the additional include paths to Pong/inc/ and SFML respectively. As I do not want to clutter your thread with my project I will setup an own project thread the coming days and leave this only here for you to dig through ;)

Cheers and TGIF!

Hapax

  • Hero Member
  • *****
  • Posts: 3346
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: My Practice Beginner Games
« Reply #7 on: August 28, 2015, 04:47:58 pm »
Just updated spin branch to be more interesting. AI was almost too intelligent so added error based on spin and reduced its maximum speed. The spin also affects the angle that it bounces too.

@SeriousITGuy
Just built your version. It's...green! hehe
Works well. Looks like you stole my keys for the stopping and resetting of the ball!  :P
Stopping the ball in yours is a little less useful since it can't be started again. Maybe you could modify it to toggle the speed rather than just zero it, or add another control to start it moving again.
One thing I did notice is that you have a method called "handleEvents" that only processes keys that are currently pressed. These are not events. They are "input", though  ;)
I'm curious, why is it labelled as a tutorial?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Cryonic

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: My Practice Beginner Games
« Reply #8 on: August 28, 2015, 09:08:01 pm »
Hmm, wouldn't you want to inline your 1-liner functions such as in "ball.cpp": "ball.getPosition()"?

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: My Practice Beginner Games
« Reply #9 on: August 28, 2015, 09:45:49 pm »
It really doesn't matter. The compiler will usually spot such things - and even if it doesn't, the performance impact is probably negligible.

Hapax

  • Hero Member
  • *****
  • Posts: 3346
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: My Practice Beginner Games
« Reply #10 on: August 28, 2015, 10:10:44 pm »
Performance-wise, there are a lot of things that could be done here. Storing results from function calls and re-using them instead of constantly calling the same functions would be prefered usually but in the case of this simple game, I don't think it requires such optimisations. It is only Pong (sort of), after all!

I sometimes even write one-liners in the header but, for interface clarity, it's better without them.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Hapax

  • Hero Member
  • *****
  • Posts: 3346
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: My Practice Beginner Games
« Reply #11 on: August 29, 2015, 03:03:41 pm »
Added a Windows build of its current state (v0.2.0) to a GitHub release.

Spin has been added to the ball for added manoeuvrability. AI has been improved and may actually be too intelligent. Tried to dumb it down slightly and gave it a speed handicap (as mentioned above).

Feedback and suggestions are wanted as, if the game is in correct working state, the next modifications are all cosmetic.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Hapax

  • Hero Member
  • *****
  • Posts: 3346
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: My Practice Beginner Games
« Reply #12 on: August 29, 2015, 03:31:51 pm »
Added video of Puzza v0.2.0 to the original post.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

SeriousITGuy

  • Full Member
  • ***
  • Posts: 123
  • Still learning...
    • View Profile
Re: My Practice Beginner Games
« Reply #13 on: September 01, 2015, 09:55:30 am »
Hi Hapax,

nice progress on your Pong. The ball spin feature gives it a very nice touch, gives me some preasure to find my own unique feature for it ;) Btw, after getting your libs included correctly building it from scratch was no problem.

For your questions: the first commit was based on a pong tutorial I read, thus the commit message. ;)
I know about handleEvents(), not satisfied with it either. It origins from my game framework which is based upon the code from the book SFML Game Developement. Maybe I make a seperate function handleInput() for the real time inputs and leave handleEvents() just for windows events which are processed in Application.cpp. Maybe when I advance my "command pattern" from simple bool values to something more elaborate ;)
And I did not stole your keys, I just had some inspiration on key bindings :p

Hapax

  • Hero Member
  • *****
  • Posts: 3346
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: My Practice Beginner Games
« Reply #14 on: September 01, 2015, 06:15:30 pm »
Hi, and thanks  :)

In yours, "tutorial" is also shown in the sub-title to the repository, directly above "5 commits".
You could just rename handleEvents to handleInput. Events are a form of inputs but not inputs are events.

No worries about the keys. Just thought F2 seemed like a good reset key  ::)
In the latest version, I've included F5 to restart completely (as in Play Again), and F6 to do the same but with the ball stopped  ;)
Speaking of the latest version, audio has been added, and the add-graphics branch is currently being worked on (it has static graphics - needs frame animation!).

Did you have any troubles with the libraries themselves? What platform are you building on?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything