Jump to content

  • Log In with Google      Sign In   
  • Create Account


Wrote First Game[SDL/C++] - Feedback


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 DZee   Members   -  Reputation: 194

Like
0Likes
Like

Posted 03 July 2012 - 07:18 PM

Hey guys, some colleague of mine asked me to learn SDL. So yesterday I went and skimmed the API along with one or two tutorials. I figured I'd start slow so I wrote this Tic Tac Toe game.

I wouldn't mind any kind of feedback either on the code or the game, anything is appreciated. It's written in C++. I was cut short because of a work project(Income!!!) so I didn't implement any proper AI unfortunately. Took around 8 hours, I had forgotten a lot of things about C++ since most of my experience comes from Java Swing(Eww). Everything is from my mind, my pencil and a blank sheet of paper. Didn't want to inspire myself from any of the popular methods for finding the winner, I will take a peek into the AI algorithm just for my personal culture though.


Expect to see more interesting games coming along with each step I take. I'm probably going to make a <game of life> type just because I'm curious and then probably a poker game(I wrote an engine in Java a year ago), then probably step away from turned based games and go on to make the best game in the worldPosted Image .


Worst case scenario this might help someone or inspire people.


Have fun.

---
Oh I forgot, my laptop is in repair so I had to use the dreaded Visual Studio so I can't offer any makefiles for Unix

-----
Oh yeah and, I haven't tried multiple grid sizes. There's no loop to construct the frame initially so that would have to be done manually... my fault Posted Image

Attached Files


Edited by DZee, 03 July 2012 - 07:21 PM.

I "surf" the web, literally.


Sponsor:

#2 fastcall22   Crossbones+   -  Reputation: 4271

Like
-2Likes
Like

Posted 03 July 2012 - 10:40 PM

The dreaded Visual Studio? Visual Studio is dreaded? Why? (Well, okay, I guess the C++11 support is somewhat lacking...)

After spending a couple minutes looking, I found a couple of odd things:
1) People still use RAR files?
2) Of the files Visual Studio generates, the only files vital to building the project are the .sln and .vcproj. The rest -- .sdf, the intellisense database; .suo, the solution options (??); the .vcxproj.user -- aren't needed, should be deleted.
3) Do not distribute the Debug versions of your executable. The debug versions of the C runtime library are intended for development only, not for deployment.
4) Multiple copies of the res directory?
5) (Nitpick) Your vcproj assumes I have SDL installed in C:\SDL-1.2.5 -- I actually have it installed in C:\bin\sdk\SDL\1.2.5. It doesn't really matter as long as your project links to an SDL.lib, and I have properly set up the appropriate directory.

I'll take a much thorough look inside your project later...
c3RhdGljIGNoYXIgeW91cl9tb21bMVVMTCA8PCA2NF07CnNwcmludGYoeW91cl9tb20sICJpcyBmYXQiKTs=

#3 arrrgh   Members   -  Reputation: 107

Like
1Likes
Like

Posted 03 July 2012 - 11:17 PM

IMO, I would replace
[source lang="cpp"] buttons[0] = new Button(0, 0, 200, 200, tileClips[Empty]);buttons[1] = new Button(200, 0, 200, 200, tileClips[Empty]);buttons[2] = new Button(400, 0, 200, 200, tileClips[Empty]);buttons[3] = new Button(0, 200, 200, 200, tileClips[Empty]);buttons[4] = new Button(200, 200, 200, 200, tileClips[Empty]);buttons[5] = new Button(400, 200, 200, 200, tileClips[Empty]);buttons[6] = new Button(0, 400, 200, 200, tileClips[Empty]);buttons[7] = new Button(200, 400, 200, 200, tileClips[Empty]);buttons[8] = new Button(400, 400, 200, 200, tileClips[Empty]);[/source]
with something along the lines of
[source lang="cpp"] const int BOARD_W = 3; // in tiles const int BOARD_H = 3; const int BUTTON_W = 200; // in pixels const int BUTTON_H = 200; int i = 0; int j = 0; for(i = 0 ; i < BOARD_H ; i++) { for(j = 0 ; j < BOARD_W ; j++) { buttons[i*BOARD_H + j] = new Button(i*BUTTON_H, j*BUTTON_W, BUTTON_H, BUTTON_W); } }[/source]

because this avoids some repetition and also allows you to change the board size easily, if you wanted to add an option for a 4x4 game, or if you want to change the tile size easily for changing screen resolution, using different graphics etc.

Edited by arrrgh, 03 July 2012 - 11:20 PM.


#4 Zoomulator   Members   -  Reputation: 269

Like
0Likes
Like

Posted 04 July 2012 - 03:19 AM

People still use RAR files?

I do.. what's wrong with rar files? =P Rather use that than zip.. JAR, now that's a legacy format. Haven't seen that in years and years
Moving on..

Your vcproj assumes I have SDL installed in C:\SDL-1.2.5 -- I actually have it installed in C:\bin\sdk\SDL\1.2.5. It doesn't really matter as long as your project links to an SDL.lib, and I have properly set up the appropriate directory.

How do you set up the appropriate directory? I've never found a good standard way for looking up libraries depending on the user. I always get frustrated with msdn. It's worked for me so far, because I mostly handle my development alone.

#5 fastcall22   Crossbones+   -  Reputation: 4271

Like
0Likes
Like

Posted 04 July 2012 - 11:30 AM

what's wrong with rar files? =P Rather use that than zip..

WinRAR is what's wrong with RAR files. I find 7-zip as a much superior (and free) alternative.

How do you set up the appropriate directory?

You can only setup the appropriate directory for your own machine. Anywhere else and you'll need to either trust the user has the appropriate directory setup or distribute the libraries with your project and use those.

Visual Studio's property sheets are a step forward, in my opinion. These allow you to change your project properties in layers. If you were to create and include in your project two property sheets, "SDL_1.2.5-debug" and "SDL_1.2.5-release", that add your SDL's include/library directories, and then distribute your project without those property sheets (remember, they reference directories in your harddrive), then the developer (once presented with an error message or reading your readme.txt) on the other side will substitute his own versions of those property sheets so that your project will point to his SDL directory.
c3RhdGljIGNoYXIgeW91cl9tb21bMVVMTCA8PCA2NF07CnNwcmludGYoeW91cl9tb20sICJpcyBmYXQiKTs=

#6 DZee   Members   -  Reputation: 194

Like
0Likes
Like

Posted 04 July 2012 - 03:42 PM

The dreaded Visual Studio? Visual Studio is dreaded? Why? (Well, okay, I guess the C++11 support is somewhat lacking...)

After spending a couple minutes looking, I found a couple of odd things:
1) People still use RAR files?
2) Of the files Visual Studio generates, the only files vital to building the project are the .sln and .vcproj. The rest -- .sdf, the intellisense database; .suo, the solution options (??); the .vcxproj.user -- aren't needed, should be deleted.
3) Do not distribute the Debug versions of your executable. The debug versions of the C runtime library are intended for development only, not for deployment.
4) Multiple copies of the res directory?
5) (Nitpick) Your vcproj assumes I have SDL installed in C:\SDL-1.2.5 -- I actually have it installed in C:\bin\sdk\SDL\1.2.5. It doesn't really matter as long as your project links to an SDL.lib, and I have properly set up the appropriate directory.

I'll take a much thorough look inside your project later...


Dreaded because I do not like how VS handles properties for different projects. Give me makefiles any time of the day. Perhaps I am just used to the Unix way of dealing with these. I do use VS at most places I work though.

1)
Well yes it's true that I did some tests at some point in time and Zip files were superior in pretty much every category against rar files. I guess I'm used to WinRar. I would have tarred it if I was on Unix.

2),3)
You are right, sorry about that I was lazy.

4)
Essentially the res directory was unique, but I copied it in the .exe for a quick run for anyone who was interesting in trying it out. I think I left the .bmp too for no reason. Packaging again, my fault Posted Image

5)
I normally use environment variables(Such as creating SDL_DIR="path"), It would have fixed your problem per se, but it would have facilitated the integration.



@arrgh, yes indeed, I mentioned the loop earlier my fault, thanks for pointing out it's importance.

---
Thanks for the input.

Edited by DZee, 04 July 2012 - 03:42 PM.

I "surf" the web, literally.


#7 BeerNutts   Crossbones+   -  Reputation: 2856

Like
1Likes
Like

Posted 05 July 2012 - 07:12 AM

The dreaded Visual Studio? Visual Studio is dreaded? Why? (Well, okay, I guess the C++11 support is somewhat lacking...)

After spending a couple minutes looking, I found a couple of odd things:
1) People still use RAR files?
2) Of the files Visual Studio generates, the only files vital to building the project are the .sln and .vcproj. The rest -- .sdf, the intellisense database; .suo, the solution options (??); the .vcxproj.user -- aren't needed, should be deleted.
3) Do not distribute the Debug versions of your executable. The debug versions of the C runtime library are intended for development only, not for deployment.
4) Multiple copies of the res directory?
5) (Nitpick) Your vcproj assumes I have SDL installed in C:\SDL-1.2.5 -- I actually have it installed in C:\bin\sdk\SDL\1.2.5. It doesn't really matter as long as your project links to an SDL.lib, and I have properly set up the appropriate directory.

I'll take a much thorough look inside your project later...


All of your arguments are nitpicks. Seriously, your 1st criticism's is he used rar for compression.

There are some valid criticism's, but your's, especially about how he distributed the code, are unwarranted.
My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS