Page 1 of 2

[BoxWar] v.0.0.3

Posted: November 30th, 2012, 9:35 pm
by Clodi
:D
Hei guys, I finally finished my first game and I'd like you to try it out and tell me what you think :)
(And thanks to Lux and other board members I finally managed to upload it!)

If you are an expert game maker (..or more expert than me.. very much likely..) could you please give me some tips about the way I code?
My "style" has to be good otherwise, if I pick up bad habits right from the start I am pretty much screwed.. I'd like my code to be very clear.

Every comment is more than welcome!! (..I am still at lesson 16 of the beginner series so.. no advanced stuff yet :| )

edit:

v.0.0.3
Major upgrades:
(1)menu in 5 languages,
(2)larger window,
(3)scores and health on screen,
(4)better vector graphics,
(5)better collision graphics,
(6)4 modes

v.0.0.2
Major upgrades:
(1)a lot of bugs removed,
(2)increasing difficulty,
(3)better enemy movement

Re: FINALLY MY FIRST GAME!!!

Posted: December 1st, 2012, 1:36 am
by Clodi
Extract before start playing :)

Re: FINALLY MY FIRST GAME!!! (edit)

Posted: December 1st, 2012, 10:45 am
by LuX
Not bad. I know it's really a personal preference, but I like how you use a lot of spaces and keep stuff organized instead of forcing everything in a tiny space. Makes following your code a lot easier.

Maybe the "box" structure could be declared in the header and then you should make constructors for it instead of making it all in the source code. But I guess both are fine as long as you won't be needing that struct outside of "Game".

Your drawing text part is a bit funny, but I guess it works for now.

PS. Your uploaded file is fine. Did you extract it before opening?

PPS. The enemies probably get stuck because you need to push them out of the wall if they get stuck. Your code doesn't properly handle this.

Re: FINALLY MY FIRST GAME!!! (edit)

Posted: December 1st, 2012, 1:51 pm
by Clodi
Thank you so much Lux for your comment!!
No, actually.. I didn't extract anything :D

Anyway.. "you need to push them out of the wall if they get stuck" Nice idea.
How can I code for that? they already "know" that once they reach the wall, their velocity should change "sign" and that means: bouncing!
I don't get why sometimes they go against the wall and then get stuck instead of bouncing. I will try to give another look at the code to see if I can implement some "brute force" method following what you said.

Re: FINALLY MY FIRST GAME!!! (edit)

Posted: December 1st, 2012, 10:47 pm
by indus
I also liked the clean coding style you have :)
You should review the random generation for the velocities.
First of all rand() % 8001 generates an integer between 0 and 8000. Than you divide it by 1000 and get an integer between 0 and 8. Finally by substracting 4 the range becomes -4 to 4.
You will get the same result by doing simply (rand() % 9 ) - 4, but Im sure thats not what you wanted ;)
The way you do it now you accept velocity of 0, in which case the enemy is going to move either only on the vertical (vx = 0), or on the horizontal (vy = 0). And it is even possible that you generate 0 for both vx and vy in which case your enemy will not be moving at all :)

Re: FINALLY MY FIRST GAME!!! (edit)

Posted: December 2nd, 2012, 6:14 pm
by Clodi
Indus, thank you so much.
I am going to have to fix the random velocity initialiser so that (0,0) is not possible.
So that the "green guys" will always be moving, and I also have to code for when they move along a straing line (x,0) and (0,y) and kick them out like Lux said.

The reason why sometimes the game crashes might be: the "Red guy", the target box to reach, the goal.
We initialise it at random and that means that it could appear exactly where we are. That could cause some problem so maybe I should put some further constraint to the random inisialisation.

Thanks for the comment on my coding style.
Everybody says that everything on the same line looks awful, and it's true.
But when statements (or functions) are so short, I think that 4 or 5 longer lines look a lot better and are more readable than 20 slightly shorter ones.

About my game in general, I am now trying to implement shooting "as a defence" against the enemies but I find it extremely hard. I coded for a couple of hours yesterday failing miserably, I will try again in a couple of minutes and see if I can manage it.
I already have perfectly clear in my head how to implement health bars and hit points and stuff but no idea how to "draw the bullet" going from point A to B when both A and B are moving..

(Somebody who already made a clone of "Space Invaders" & Co. could/should help me :D)

Clodi

Re: FINALLY MY FIRST GAME!!! (edit)

Posted: December 9th, 2012, 9:49 am
by chili
Good work on your first game brah. Your code formatting is pretty good and the comments make it really easy for even someone who is unfamiliar with the code to navigate it smoothy. Also, the general structure of your code is nice and logical. A very nice start Clodi. :)

Re: FINALLY MY FIRST GAME!!! (edit)

Posted: December 15th, 2012, 10:51 pm
by julius
not bad. i like the effort you put into it.

Re: FINALLY MY FIRST GAME!!! (edit)

Posted: December 17th, 2012, 12:25 am
by Clodi
Thank you Chili and Julius,

It means a lot. :D

edit:

:oops:
..I still can't believe I don't know how to prevent those stupid little green squares from getting stuck when hitting the walls. I made very slight changes to the code and I still can't figure out why sometimes they get stuck. It happens sporadically but it pisses me off. It feels like I have no actual control over my own code which sucks. :?: :?:

Re: FINALLY MY FIRST GAME!!! (edit)

Posted: December 24th, 2012, 7:05 pm
by Clodi
Hello guys :)

This is my new version.
A gift from me for Christmas 8-)
I think it's pretty cool and it works fine too.

One question, can anybody, after building and compiling, try to run the debug version or release version from the folders ( without entering the solution folder and using VC++) ? :?:

If I do so, it doesn't work and it gives me an error!! AND this implies I can't give it to anybody who hasn't got VC++.. :cry:
Let me know what you think about the game and whether or not your debug/release versions work fine and have a very happy Christmas!