Computer Science Canada

Geometry Wars Clone

Author:  TerranceN [ Sat Feb 20, 2010 12:12 pm ]
Post subject:  Geometry Wars Clone

This is my final project for ICS 4UI, but I have added some stuff onto it, and I will be updating this when I have the time (aka after the CCC and Math competition).

I used Win32 and OpenGL to create this, and used code from Neon Helium (specifically lessons 1 and 13), although I have changed it in order to be OO.

NOTE : In order to save your highscore, the exe must not be in the zip.

NOTE 2 :This will only work at 1280x1024 (4:3) fullscreen right now. Once I get the menu finished it will be changeable in-game. If you need a different resoloution, just ask, or go into the source code and change the resoloution in main.cpp.

NOTE 3 :The code is horribly commented right now, I will comment it further when I have time.


Controls
W, A, S, D or UP, DOWN, LEFT, RIGHT -----------Movement
Left Click ------------------------------------Fire Bullets
P ---------------------------------------------Pause
Escape-----------------------------------------Exit to Main Menu


My best score : 191,200

What do you guys think and what should I name this (as I am horrible at coming up with even semi-decent names)? Also, if you find any bugs please let me know.

Author:  TerranceN [ Mon Mar 01, 2010 5:56 pm ]
Post subject:  Re: Geometry Wars Clone

Update!

New Stuff
-Added menu input
-Can change resoloution
-Can save settings
-Automatically loads settings

In order to save your settings or highscore, you must first extract the exe. Sorry for how messy the code is. I should probably also mention that this was made in Microsoft Visual C++ 2010 Beta2.

Author:  SNIPERDUDE [ Mon Mar 01, 2010 10:59 pm ]
Post subject:  RE:Geometry Wars Clone

Being on a laptop with no proper mouse, I didn't get too far - but from I've seen it's pretty cool.
+bits

Author:  TerranceN [ Thu Mar 18, 2010 10:16 pm ]
Post subject:  Re: Geometry Wars Clone

Update!

Sorry it has been a few weeks since the last update, but I decided to take a break (until now), and my Microsoft Visual C++ 2010 Beta 2 got messed up when I uninstalled the C# 2010 Beta, requiring me to reinstall lots of stuff until I found the problem. Anyway...

New Stuff
-Added a score multiplier, you get +1% per kill, and you go back to 100% if you die.
-Added grid effects:
-----Grid is now distorted by your shots (it only has small effect with 1 bullet, it is best at 3+ bullets)
-----Grid has higher resolution
-----Grid now coloured to make 4x4 sections
-Enemies spawn slower
-When you die, you only loose 1 bullet per shot, instead of going back to 1.

Known Bug(s)
-After going fullscreen the desktop is the active window, you need to click on the game in order to play.
-I completely forgot to increment the version number in the window title before uploading... oh well.

Author:  SNIPERDUDE [ Thu Mar 18, 2010 10:37 pm ]
Post subject:  RE:Geometry Wars Clone

I much prefer Dev-C++, it doesn't give me nearly as many problems as Visual Studio does. Also, I like being able to create a file, and run it without having to create a project to go with it.

Author:  TerranceN [ Thu Mar 18, 2010 10:45 pm ]
Post subject:  Re: RE:Geometry Wars Clone

SNIPERDUDE @ Thu Mar 18, 2010 10:37 pm wrote:
I much prefer Dev-C++, it doesn't give me nearly as many problems as Visual Studio does. Also, I like being able to create a file, and run it without having to create a project to go with it.


For small projects and testing small chunks of code, I agree, but intellisense is very useful on more complicated projects (dev-c++'s intellisense is slow and not very smart; when I have a method with the same name in two different classes, it cannot tell the difference between them, and gives me the parameters for every Update method in the entire program, forcing me to go look at the header anyway). I did try at one point to switch to dev-c++ (so I could work on it at school), but it gave me some confusing error about iterators.

Author:  SNIPERDUDE [ Thu Mar 18, 2010 10:51 pm ]
Post subject:  RE:Geometry Wars Clone

I hardly stick to one IDE, but given that I'm typically working on smaller stuff for school I tend to lean toward Dev more often than not.

Author:  X Abstract X [ Fri Mar 19, 2010 1:29 pm ]
Post subject:  Re: Geometry Wars Clone

I'm posting simply because this deserves a post. Amazing work! Oh, and I was under the impression that ICS 4U was always taught using Java.

Author:  TerranceN [ Fri Mar 19, 2010 2:47 pm ]
Post subject:  Re: Geometry Wars Clone

X Abstract X @ Fri Mar 19, 2010 1:29 pm wrote:
I'm posting simply because this deserves a post. Amazing work! Oh, and I was under the impression that ICS 4U was always taught using Java.


It was taught with Java, but my teacher was very lenient, letting use any language we wanted for our summative, and I honestly hate not having pointers and operator overloading, so I decided to use a different language. I only chose C++ because of the awesome openGL tutorial on http://nehe.gamedev.net/, but in retrospect I am finding C# a much more programmer friendly language, and would use that if I create another large-ish project.

Author:  SNIPERDUDE [ Fri Mar 19, 2010 4:09 pm ]
Post subject:  RE:Geometry Wars Clone

Each to their own I guess, given the choice I'd take C++ over C# (and definitely over Java). And Python over C++.

But having looked at that tutorial you linked, that was exactly what I was looking for, thanks.

Author:  Sur_real [ Sun Mar 21, 2010 6:19 pm ]
Post subject:  RE:Geometry Wars Clone

Java in ICS 4U, what did you guys learn in 3U then? Cuz I was taught Java in 3U and PHP now in 4U
I guess you probably learned more advanced Java or something Very Happy

Author:  TerranceN [ Sun Mar 21, 2010 7:15 pm ]
Post subject:  RE:Geometry Wars Clone

It's a little complicated...

My school is very new, and because of that, we did not have a very knowledgable computer science teacher, but it is not his fault, it was him or no computer science class. Anyway, he taught us Turing for ICS 3U; right from a word doc, giving us a week worth of programs on even the most basic stuff (whoops going a little off topic). But this year they 'restructured' the program, and we got a new teacher, which ended up in ICS 3U and 4U being taught Java. Sadly that meant the 4U barely learned anything more then 3U (we did not even 'learn' objects Sad).

So we did not learn Java in 3U, and we did not learn more advanced Java in 4U, but future students probably will.

Author:  neoaikon [ Sat Apr 10, 2010 9:31 am ]
Post subject:  Re: Geometry Wars Clone

I love this submission, it's a shame so many other clones have gotten taken down off the web.

Looking through the source code, I found one little error. When steering the ships toward the player's ship, if you notice the movement is somewhat snakelike. This is because when clamping the velocity on the baddies, you don't normalize the clamp values. This means to the baddies having a diagonal velocity >5.
code:
float angleToPlayer = atan2(playerPos.Y - position.Y, playerPos.X - position.X);

velocity.X += cos(angleToPlayer);
velocity.Y += sin(angleToPlayer);

HelperFunctions::CapFloat(velocity.X, -5.0, 5.0);
HelperFunctions::CapFloat(velocity.Y, -5.0, 5.0);


The fix is simple:

code:
float angleToPlayer = atan2(playerPos.Y - position.Y, playerPos.X - position.X);

velocity.X += cos(angleToPlayer);
velocity.Y += sin(angleToPlayer);
[b]Clamp.X = cos(angleToPlayer);
Clamp.Y = sin(angleToPlayer);
Clamp.X = (abs(Clamp.X));
Clamp.Y = (abs(Clamp.Y));       [/b]

HelperFunctions::CapFloat([b]velocity.X, -5.0f * Clamp.X, 5.0f * Clamp.X[/b]);
HelperFunctions::CapFloat([b]velocity.Y, -5.0f * Clamp.Y, 5.0f * Clamp.Y[/b]);


This ensures the velocity is 5 in all directions. If you look at the difference you'll see the baddies smoothly track toward the player.

Author:  ScaryRat [ Sun Apr 18, 2010 5:42 pm ]
Post subject:  RE:Geometry Wars Clone

How do I open this project? Theres no SLN file.

Sorry I'm noob. xD

Author:  TerranceN [ Sun Apr 18, 2010 8:53 pm ]
Post subject:  Re: Geometry Wars Clone

Sorry I have not updated this in almost a month, I have been busy with other things.

Thanks neoaikon, I often forget about the length of vectors being greater than their componenets (I also did this in my player class IIRC). I agree, it is a shame others have been taken down, but I have only heard of gridwars getting taken down, and I doubt mine will get as known as gridwars (and if it does, then I will just be happy for the recognition).

ScaryCat, I checked and there is a sln file there. AFAIK, you should be able to open the vcproj file anyway.

As for the game, I have only added a few grid effects and did some bug fixes, so I will wait for a bigger addition to remove all the stuff msvc puts in the source folder and release the source. Speaking of bigger additions, I have been working to get some audio in the game. I have written code that will work for this, I just dont have any sounds yet. Hopefully I can use my rockband mic to record some random noises (that dont kill your ears) before the end of next weekend. I have no idea when I'll get around to adding more enemies. Oh and my highscore is 1,020,198. Very Happy

Author:  Neu [ Tue May 11, 2010 5:26 pm ]
Post subject:  Re: Geometry Wars Clone

Cool, like the grid effects, any update on this?

Author:  TerranceN [ Thu May 20, 2010 6:41 pm ]
Post subject:  Re: Geometry Wars Clone

Sorry for being slow at updating, school has got me doing so many things I'm uninterested in every day, it's hard to get motived afterwards. Either that or I just needed a break from this project.

Update:

- Game now scales depending on the set resolution, so it is now playable in its default 800x600 configuration
- Added sounds, no background music yet, but once you listen to my crappy sound effects you'll realize that may not be a bad thing
- Split up the graphics and audio portions of the settings

If anyone wants to make any sound effects or music, I will gladly make credits and include you in them. Also you can just replace the .wav files to change the sounds if you don't like them.

Any comments, suggestions, and the like are appreciated.

Author:  Tony [ Thu May 20, 2010 6:53 pm ]
Post subject:  Re: Geometry Wars Clone

TerranceN @ Thu May 20, 2010 6:41 pm wrote:
If anyone wants to make any ... music


http://dig.ccmixter.org/music_for_games under various Creative Commons licenses, typically "Attribution, Non-commercial", but check the details.

Author:  TerranceN [ Sun Jun 06, 2010 9:42 pm ]
Post subject:  Re: Geometry Wars Clone

Update:

-Added 3 new enemies:
- Purple square, breaks into 4 purple triangles when killed
- Purple triangle, drifts until it hits the wall; gets in your way
- Green squares, dodge your bullets

-Changed how long it takes to get bullet upgrades; <enemies_you_need_to_kill> = pow(2, <current_bullets_per_shot> - 1) * 25

-Added new 'type' of particle that doesn't affect grid so I can make more particles for explosions

-The enemy that killed you is showed while you wait to spawn

Author:  BigBear [ Sun Jun 06, 2010 10:07 pm ]
Post subject:  RE:Geometry Wars Clone

Awesome game that just keeps getting better and better.

Still can't figure out how to compile the source for custom edit Smile

Would be nice to have a pause button, when you press ESC it ends your game.

Also, I'm not sure if it is the number of enemies or the triangle particles that explode on the edges but this new version seems to lag for me.

Author:  TerranceN [ Mon Jun 07, 2010 2:53 pm ]
Post subject:  Re: RE:Geometry Wars Clone

BigBear @ Sun Jun 06, 2010 10:07 pm wrote:
Awesome game that just keeps getting better and better.

Still can't figure out how to compile the source for custom edit Smile

Would be nice to have a pause button, when you press ESC it ends your game.

Also, I'm not sure if it is the number of enemies or the triangle particles that explode on the edges but this new version seems to lag for me.


Thanks.

I used msvc 2010 Beta2, and I had to add some custom project options (to include the proper libraries, make it point at the right directories, etc). I know this doesn't compile in Dev-C++, some problem about iterators. If you could post the error message I might be able to tell you whats wrong.

There is a pause button, P.

Well then I guess I will need to add some more graphics settings, so you can turn down some grid effects and number of particles per explosion. Was the lag constant, or did it kind of pause for a second then continue fine? If so then I know whats wrong.

Author:  BigBear [ Tue Jun 08, 2010 2:14 pm ]
Post subject:  RE:Geometry Wars Clone

Well it definitely spikes, does it have anything to do with more bullets seems to lag when i get 4 and then get 5 except it lasts for a bit and then runs better then spikes again.

Here is a Pic of trying to run it in dev C++. I opened main.cpp and tried to run it.

Author:  TerranceN [ Tue Jun 08, 2010 2:40 pm ]
Post subject:  RE:Geometry Wars Clone

The only thing I can think of is now that I have lots of sparks it may be trying to remove too many at a time (it removes all dead ones regardless of how many there are). I will try to replicate this problem on my laptop.

The ones at the bottom are the cryptic iterator error I mentioned earlier, and the openAL ones are because you did not configure it to use the openAL headers and libraries. All the rest I see are warnings.

Author:  Quakerstate98 [ Fri Sep 03, 2010 1:09 am ]
Post subject:  Re: Geometry Wars Clone

just posting to say, very good work! I look forward to the days that I can make programs as good as this Smile

Author:  TerranceN [ Fri Sep 03, 2010 8:14 am ]
Post subject:  RE:Geometry Wars Clone

Thanks for the encouraging comment, but just a heads up, I wouldn't use this an example to learn from. This was when I didn't fully understand how C++ manages memory, and therefore is a giant memory leak (don't worry, it leaks slow enough I didn't notice it when testing it, so it should not cause problems unless left open and played over a long period of time, and as long as your OS is fairly recent, it should free this memory when the program closes). Also I used win32 which I never want to use again, I will just use SDL.


: