Page 1 of 1

looking for critique on first game.

Posted: April 23rd, 2017, 3:59 pm
by coolmoon
so i am only to lesson 12 but wanted to try a game on my own.
I made a straight up game of pong and called it ping.

Game play
left player "w" and "s" for up and down.
right player up and down arrows
enter to start game
space bar to serve
ball speeds up every 3 hits and resets each serve
first to 10 wins

I did jump to lesson 15 first so I could get it up on GitHub.
https://github.com/CoolMoon1/Ping

it is only self commenting, I hope well enough.

I know there better ways to get this done code wise but the only thing I used not in the lessons was a switch/case for the score, my main concern is the game development ie..

I would like to know if my commits to GitHub were timed / spaced right and what order of game development might have made it easier. this is just how it fell out of my head without planning it out on paper.

all comments on code or development are welcome

Thanks for your time.
CoolMoon

Re: looking for critique on first game.

Posted: April 23rd, 2017, 9:44 pm
by albinopapa
My first critique would be the Ball class handling score and game over conditions.

Good use of const

Code: Select all

Player::Player( int in_x, int in_y, int in_width, int in_height, int in_speed )
{
	x = in_x;
	y = in_y;
	width = in_width;
	height = in_height;
	speed = in_speed;
}
I don't remember at what point chili covers constructors, but for future reference when initializing class members, it's better to use the initializer list opposed to the constructor function body like so

Code: Select all

Player::Player( int in_x, int in_y, int in_width, int in_height, int in_speed )
	:
	x( in_x ),
	y( in_y ),
	width( in_width ),
	height( in_height ),
	speed( in_speed )
{}
Not so much an issue for small applications or objects you create during application startup, but it is a good habit to get into. There are going to be times you are required to do so, and it is actually more efficient to do so.

Try to keep game logic out of your drawing routines, in Player you have clamping code in the draw function, you could move this to the Update function. Also, in your Game::ComposeFrame function

Code: Select all

	if( !ball.InPlay() && wnd.kbd.KeyIsPressed( VK_SPACE ) && isStarted )
	{
		ball.ResetBall();
		wnd.kbd.Flush();
	}
This looks like game logic, so should probably go in Game::UpdateModel

Re: looking for critique on first game.

Posted: April 23rd, 2017, 10:09 pm
by albinopapa
Just saw something else that might be useful to you and maybe others.

In VS there is something called a Task List, by using those //ToDo or //TODO tags, you can keep track of your "TODO's". If you don't have that tab at the bottom, you can go to View / Task List to add it.

Re: looking for critique on first game.

Posted: April 23rd, 2017, 10:48 pm
by coolmoon
Thanks albinopapa,
all feed back is welcome. I want to start forming good habits from the start.
I will study up on the initializer list.
Also the //ToDo tip will be helpful, I found myself lost a couple of times or at least wondering what I needed to do next.

Thanks again

Re: looking for critique on first game.

Posted: April 24th, 2017, 10:06 am
by chili
Looked at your code, looks like good stuff. Same comment as papa really, ball should not be responsible for score.

And I also was not aware that VS now has a todo tracker. I'll have to use that myself, maybe in a future video.

Re: looking for critique on first game.

Posted: April 24th, 2017, 4:50 pm
by albinopapa
The only thing I don't like about the Task List is it only shows the todos when those documents are open. So if you have a bunch of todo comments in several files, you'd still have to open them up before the Task List would show the comments. Though if the file is really long, using the Task List to navigate to that comment by double clicking is nice.

Re: looking for critique on first game.

Posted: April 26th, 2017, 7:10 am
by LuisR14
has been available on vs2015 (don't remember if even earlier)

Re: looking for critique on first game.

Posted: April 26th, 2017, 7:56 am
by albinopapa
Yeah, if I remember correctly, VS2013 had it and had more options like User Tasks which allowed you to add a task list and check them off as you completed them. It was removed in VS 2015 though.

Visual Studio Task Lisk