Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / How to make my enemy fire?

Author
Message
Ovan35
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 14th Oct 2009 01:15
I\'m running into a snag here as far as the enemy.Basically I\'m working on a vertical shooter.I thought I would start simple first.The enemy would be created randomly somewhere at the top of the page.The plane would move straight downward.As it\'s flying down it will fire a bullet straight down from it\'s location.

The last part is the part I\'m having trouble with.Right now the code will produce a bullet from one plane and then after that nothing.If I put the function in the game loop section then each plane will produce a flickering bullet that will not go anywhere.I\'m not sure how to get it to do what I want it to do..But here is the relevant code that I have so far.

enemy.h- controls the creation and behavior of my enemies


The enemyFire() function is where I believe the majority of the problem is.But I honestly can\'t figure out what I might do to fix it.Any suggestions would be welcome

It was such a small seed... I needed to find out what was growing inside. And there was only one way to find out. So I decided to raise it.

Ultimate_H
15
Years of Service
User Offline
Joined: 11th Mar 2009
Location: A place that is neither here nor there
Posted: 14th Oct 2009 01:49
What it looks like is happening, is that you are moving the sprite from the top to the bottom inside a single loop. basically what is happening is when the bullet is fired: everything stops, place bullet sprite, move sprite as if it were normal, keep moving until it reaches the end of the loop, go back to game play. To fix this, you usually want to move the bullet once(or less) per pass in the main loop. I would also change the chances down from a 50% chance, this usually rains bullets down. I find it nicer around 20-30% personally.

Something like this:



hope that helps

If I sound like I know what I am talking about, then I most likely have no idea what I am saying.

If I sound like i have no idea what I am saying, then I most likely know what I am talking about.
Ovan35
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 14th Oct 2009 02:18
The enemy keeps going down the screen.That part is correct.It's just the fact that it will only fire once.No other plane will fire.Everything else works fine so far as the planes moving downward, disappearing and repositioning at the top of the screen when they are either shot or when they make it to the bottom of the page.Like you said given the loop set to 50% they should be raining down bullets but they are not.I did try your code though but same problem.

It was such a small seed... I needed to find out what was growing inside. And there was only one way to find out. So I decided to raise it.

Ovan35
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 14th Oct 2009 19:16
I have tried several different forums.Noone seems to be able to answer my question here.So maybe I have the wrong approach.I'm sure there have been others that have tried a vertical shooter in dark GDK... what was your approach to getting enemies to fire.I'm not afraid of rewriting if I have to.

It was such a small seed... I needed to find out what was growing inside. And there was only one way to find out. So I decided to raise it.

Ovan35
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 14th Oct 2009 20:09
With some tinkering I was able to get it to work but at the sacrifice of being able to control the speed.I will continue to work on it however.The problem right now is the bullets are coming out from each plane.. but they are moving much too fast to be dodged.the dbMoveSprite command seems to have no effect of the speed of the bullet.When I tried removing the spriteY++ line and replacing it with a dbMoveSprite command nothing would happen.The planes didn't fire any bullets.


It was such a small seed... I needed to find out what was growing inside. And there was only one way to find out. So I decided to raise it.

Login to post a reply

Server time is: 2024-11-20 13:29:09
Your offset time is: 2024-11-20 13:29:09