It has been weeks since last I posted but believe me I've been working on the project.No.. really...I've been working on it.I got the score to be placed on the screen.I fixed the explosion problem so that it will search for the beginning portion of the explosion sprite.Then when it finds it the program will continue the frames all the way to the end.I even put in game states so I will have a title screen, the actual game play and of course a game over screen.So see I was working.
So now with the problems so far.Right now when the game over screen comes up I can't seem to get it to go to the title screen.I'm not sure why it won't but I will continue to work on it.The same problem that I was having with the score problem I am having with my title screen...I want there to be some text at the bottom of the screen telling the player to press space bar to start.But for some reason the text appears underneath the title screen graphic.I tried the same trick that I used for the score but it didn't work.Unkonown why....The other thing that happened was that if you do get it to go to the title screen when you click fire the game starts over but no enemy planes appear and my bullets for some reason are invisible the second time around.So I have a few issues to work out before I can move on.
Other future changes I would like to try for Prometheus are:
1)A boss at the end of the level 2)smarter enemies...Not just random ones 3) multiple levels 4) scrolling background
There seems to be no end to the problems I encounter.Maybe it's lack of understanding the fundamentals...I'm not sure.Ok update so far.After my last problem I was pumped to get back into the project.I have the enemies moving down the screen.They fire at random times.I also implemented some of the things I was telling you about earlier.I have the boundaries set.The player can't just go off the screen to avoid enemy fire.I even did some fine tuning to make it where the plane will only fire once the enemy plane is on screen.(That's the one thing I'm learning is that when programming you can't take anything for granted.Hell even gravity has to be put into a game.Anyway on with the problem.I've been working on two problems.
(1). I'm trying to get the enemy planes to explode when hit by my bullet.Nothing seems to happen no matter how I code it it or where I put it.
2) When my player plane is shot I want iit to disappear for a few seconds.Then reappear for more game play..
right now neither aspect is working.But I will continue to work on it .. and of course if I have an answer I will place it here..Anyway it's 5:20 and I'm starting to dream I'm typing these words.. so that's my cue...Goodnight all.
Well it took me a while but I did figured it out.What I had to do essentially was to number one put it in the while loop of the main.cpp file.Even then though all I was getting was these flickering bullets that wouldn't go anywhere.Thanks to a good hint from thegamecreators.com forum section I got the idea of making a bool..This bool would be a switch of sorts to tell the enemy ships it's alright to fire.That allowed the loop to work as intended where all the planes fired instead of just once.The third part of making it work was making a if statement that kept track of how far down the screen the bullet had gone and switching the bool to false when it got below the screen so the for loop would begin again.One problem solved but it's not over yet. I have alot to do with this game before I can call it complete.Right now I'm working on the boundaries so that the player can't just go outside of the screen to avoid shots.Then I can work on making a scoring system, making the player capable of taking damage and putting a explosion effect in for when you destroy the enemy or vice versa.
Below is the code on the enemy.h file..The primary source of the problem I was having.
void
{
enemy()
// in this loop we're going to create some animated sprites, the image
// we load contains frames of animation for an asteroid
{
dbLoadImage (
for ( int i = 5; i < 9; i++ )"enemy.bmp", i );// position our sprite at a random location
dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i );
dbScaleSprite(i,50);
}
}
void
{
{
enemyFire()for (int i =5; i <9; i++)int fire = dbRnd(100); //set a random value to fire
if(fire >85 && spriteshot == false) //if fire is greater than 85.
//Decrease this number if you want to increase rate of fire
{
{
for(int j = 10; j < 15; j++)if(dbSpriteY(i) > 0) //enemy has to be on screen before they can fire
{
//Create Bullets at the sprite
dbSprite(j,dbSpriteX(i)+25, dbSpriteY(i)+ 25,4);
spriteX=dbSpriteX(i);
spriteY=dbSpriteY(i);
spriteshot=
}
}
true;//end for loop
}
//end if(fire >85...
if
{
{
dbMoveSprite(j, -4);
(spriteshot==true)for(int j = 10; j < 15; j++)//Move our enemy bullets down the screen
if(dbSpriteY(j) > 600 && spriteshot == true) // if the bullet goes offscreen
{
spriteshot =
false; // turn spriteshot to false so our planes can make another bullet
Alright so just as I promised I would put up some of the code that is causing the problem.Alright to recep I'm working on the enemy right now.It's a very simple minded enemy.Most of it if not all of it relies on random events.First off the enemy appears on the top of the screen and moves straight downward.During the trip downward at a random moment the enemy ship can send a bullet straight down.If the enemy is shot the enemy is deleted and recycled to be placed at the top of the screen again .If it reaches the bottom of the screen the enemy is repositioned to the top to begin his run again.From the players point of view the enemy will look like it's been destroyed by the bullet, or the enemy has escaped his wrath respectively.Now for the code
enemy.h - this is where I put the code for enemy behavior.The code is pretty well commented I think.We start off with a for loop.In Dark GDK each sprite has its' own ID number.This sprite id is how you refer to the sprite you want and create it as well.So I created a for loop that would loop through numbers 5-9 and create 4 sprites and place them at random positions at the top of the screen.
void enemy()
{
// in this loop we're going to create our enemy sprites
for( int i = 5; i < 9; i++) {
dbLoadImage ( "enemy.bmp", i); //position our sprite at a random location
{
dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i );
dbScaleSprite(i,50);
}
}
Now this part is largely where I'm having the trouble with.The idea of enemyFire() is to cycle through each of our enemy sprites.As you can see you have another variable called fire.Fire picks a random number of 1-100.If Fire is a number that is greater than 50 the enemy should fire.But like I said in the last post..For some reason only one ship fires..Usually very early in the game..And it only does it once.I thought about putting it in the loop part of the main.cpp file but when you do that ships all produce bullets but none get fired..Bullets are created but they never really go anywhere.they simply flash in and out.So that's my problem right now.
void enemyFire() { for (int i = 5; i < 9; i++) //cycle through our sprites again { int fire = dbRnd(100); // pick a random number 1-100 if (fire >50) // if the number is higher than 50 { for(int j=10; j < 15; j++) //make 5 bullets { dbSprite(j, dbSpriteX(1), dbSpriteY(i), 4); //create those bullets at the enemy location that wised to fire } }
Well here I am.This isn't the first time I've tried this.But hopefully this will be the time it will work.The idea is quite simple to make a record of what I've done as far as game development.I wish I could say this project was some ultimate project..The pinnacle of all my knowledge and skill but sadly in alot of ways I am just getting started in the world of game programming.I've had alot of false starts and half finishes.Most of which I think are largely connected to my choice for first programming language.I chose c++ for my first.Seemed logical at the time.You look for game tutorials on the net and the majority of them are written in c++.Which you think would mean more references and thus a greater chance of you picking up the essentials.I did pick up alot but I also kept running into dead ends as well.So I decided to look around for other alternatives and I think I have it.Dark GDK. Not exactly a whole new programming language... it largely uses c++ but due to the library that comes with it.It makes game programming alot easier and I will not have to start back over with learning a whole nother language.
So Far... Well right now I've started making a vertical shooter as my first project.Getting the plane to move, fire bullets, even adding sound and music was easy.Now I am working on the enemy.So far what I've done is have the computer create 4 enemies... those 4 enemies will be recycled. So if one is shot the score is calculated, displayed and the enemy plane destroyed and brought to the top of the screen where he goes down again.If the enemy plane reaches the bottom of the screen it's position will be changed to the top of the screen for it to come back down again.The enemy firing at the plane has been something I've been having trouble with.Right now only one plane will fire.. like early on in the game and no other plane after that will fire.I'm not sure what I can do on that.
I hope to follow with some code soon enough so that you guys might get an idea of what I'm talking about...But for now it's late I'm going to take it easy for the rest of the night and get a fresh start tommorow.