# Visual Basic > Games and Graphics Programming > Game Demos >  C++: Space Invaders [Source]

## Electroman

Here is a same game I made for Uni. I wouldn't say its totally finished but it is good enough to play.

Don't be afraid of getting shot, the player doesn't die but will get injured. I haven't yet done anything that will make you proper dead if you get to damagd though. The player does regenerate if you do get shot. There is also modelling that means depending where you get shot the effect will be diferent  :Wink: .

Ow well, Enjoy  :Big Grin:  :Big Grin: .
The Source is in VC++6  :Wink: . The Graphics Engine isn't mine, I am working on my own that will be in VC++.NET and more optimised though  :Wink: .

BTW the exe is included incase you don't have a C++ compiler  :Wink: .

_EDIT: Updated the file._

----------


## SLH

It ran way too fast on my computer, guess you altered the game loop just before zipping up the project or something.....

From what i could see it looks good though.  :Smilie:

----------


## Electroman

Strange, the Timer code is actually part of the engine that the lecturer made. Its meant to use the performance counter thing to make each frame 20ms  :Confused: , will check it out though.  :Big Grin:

----------


## Electroman

Try setting a break point on the line I highlighted and see if it gets run. If it does then it would explain it:


```
GameTimer::GameTimer()
{
    if(QueryPerformanceFrequency(&freq)==0)    // Find the timer frequency
    {
        freq.QuadPart=0;    // Set to zero if function failed
    }

    mdGameRate = 1.0;
}
```

This code is in the gametimer.cpp  :Wink: .

----------


## SLH

Nope. Doesn't get ran.

EDIT: Just noticed, it's doesn't run fast ALL the time, very occasionally it'll slow down to roughly normal for about half a second. Very strange.....  :Confused:

----------


## Electroman

yea I feel a bit silly now, I just checked and the timer isn't used at all  :Frown: . I'm sure it used to be. I'll try and add it in now....

----------


## Electroman

There we go, I fixed it, the Timer code weren't half messed up too, I had to edit it quite a bit to get it to work. I acidently set the delay to 20 when testing it, not realising it was in seconds, took me ages to get out of the game  :Frown: .

----------


## wiccaan

Heh fun little game, cool addon too when you get hit you slow down and cant move for a sec. But yea, runs fast on my computer a little.

----------


## Helix11

Hey i have been toying around with your code as a learning tool and it has been great. Right now iam trying to rotate the sprites you have input. How would you go about doing that? Right now i have tried adding in 

DDRAW_INIT_STRUCT(ddbltfx);
ddbltfx.dwRotationAngle = angle;

and DDBLT_ROTATIONANGLE to the Blt.

That all does not seem to be working, when i run the code nothing appears. All the sprites do not load but the game is still running,.

----------

