• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

Dwarf with Axe

Need some help with bullets...

8 posts in this topic

Well I''ve tried other forums and they''re no help. I''m trying to create a galaxian/space invader clone, and everything should be pretty easy EXCEPT the bullets! I can''t think of how to implement the shooting... Are there any tutorials on the net (sure they''re are) and could you link me to them? THanks.
0

Share this post


Link to post
Share on other sites
Try looking up projectiles.

Why don''t you write a bullet class and spawn/delete bullets as nessesary. The class would include position, direction , velocity as well as sounds/graphics (or pointers to) and damage information/type (explosion radius etc).

,Jay
0

Share this post


Link to post
Share on other sites
Thanks!

That''s what I have so far, but I think I am thinking too technically . It has to be easier than I am thinking, because right now, I have about 3 different classes and structs just to manage the bullets...

And they still don''t work!

~Dwarf
0

Share this post


Link to post
Share on other sites
hiya dwarf, do you already have a timer control in your game? well, everytime the player presses the spacebar, activate the timer for the bullet, ie,

when the user presses spacebar:
fire = true;

if(fire = true)
{
bullet_Y -= (your variable here)
}

well, that''s all what i can think off, hey if you''re still having a problem, ICQ me, 141451718, i''ll happily help you out,
0

Share this post


Link to post
Share on other sites
Yes you can increment the Y by a static velocity like 5. (y-=5) but most of the time you want to have a velocity which can slow down & go faster depending on certian conditions. So it''s easier to do something like this

struct bullet
{
int x;
int y;
int vel;
};

bullet mybullet;
int InitialVelocity = 5;

// Do this in your startup initialization.
mybullet.vel = InitialVelocity;

// when the fired button is pressed.
mybullet.x = ( (ships.x1 + ships.x2)/2); // this puts the bullet at the middle location of your ship.

mybullet.y = ships.y1;


// do this in the frame update
mybullet.y += mybullet.vel;

now if you want the bullets to move faster say you pickup a "rapid fire" power up, you can just do...
mubullet.vel = 10; and your bullets will move alot faster. Or should you need to slow things down you can just do mybullet.vel = 2;





0

Share this post


Link to post
Share on other sites
I forgot some stuff so let me do this again..

// is the bullet alive or dead?
#define ALIVE = 0;
#define DEAD = 1;

struct bullet
{
int x;
int y;
int vel;
int state;
};

bullet mybullet;
int InitialVelocity = 5;

// Do this in your startup initialization.
mybullet.vel = InitialVelocity;

// when the fired button is pressed.
mybullet.x = ( (ships.x1 + ships.x2)/2); // this puts the bullet at the middle location of your ship.

mybullet.y = ships.y1;
mybullet.state = ALIVE;


// do this in the frame update
if(mybullet.state == ALIVE)
{
mybullet.y += mybullet.vel;
}

// check to see if the bullet is dead or not..
if( CollideWithAlienOROffScreen(mybullet) != FALSE )
{
// turn it off.
mybullet.state = DEAD;
}



now if you want the bullets to move faster say you pickup a "rapid fire" power up, you can just do...
mubullet.vel = 10; and your bullets will move alot faster. Or should you need to slow things down you can just do mybullet.vel = 2;




now keep in mind this is just one bullet, if you want more than one bullet you''ll need to use an array or linked list of bullet structures and modify the code accordingly.
0

Share this post


Link to post
Share on other sites
You could implement a linked list... I don''t know if you have already...
Example:

class Bullet
{
public:
float x, y;
float xvel, yvel;
Bullet *next_bullet;
Bullet *last_bullet;
void AddBullet(Bullet *pParent);
void DeleteBullet(void);
};
void Bullet::AddBullet(Bullet *pParent)
{
Bullet *pNew;
pNew = new Bullet;
pNew->last_bullet = pParent;
pNew->next_bullet = NULL;
}
void Bullet::DeleteBullet
{
Bullet *next;
Bullet *last;
next = this->next_bullet;
last = this->last_bullet;

// skip current bullet, then delete
next->last_bullet = last;
last->next_bullet = next;
delete [] this;
}

This probably won''t work (so don''t compile it! ), but it might get the idea across... And then during the gameloop you''d have to create some kind of loop that walks through each bullet and does its ai. Look up a linked list tutorial in the Articles section if you don''t understand them...
Goodluck!
-Jesse


| The Hitchhiker''''s Guide to Programming |
"That is not dead which can eternal lie,
And with strange aeons even death may die."
-H.P. Lovecraft
0

Share this post


Link to post
Share on other sites
If you have a copy of UnrealEd look at the weapon classes there, they are all subclassed from a standard weapon class with different Touch (bullet projectile hit) etc. methods.

It makes it very easy to add new weapons etc (Exploding Pigeon Crossbow).

,Jay
0

Share this post


Link to post
Share on other sites
quote:
Original post by Aphelion
You could implement a linked list... I don''t know if you have already...
Example:

class Bullet
{
public:
float x, y;
float xvel, yvel;
Bullet *next_bullet;
Bullet *last_bullet;
void AddBullet(Bullet *pParent);
void DeleteBullet(void);
};
void Bullet::AddBullet(Bullet *pParent)
{
Bullet *pNew;
pNew = new Bullet;
pNew->last_bullet = pParent;
pNew->next_bullet = NULL;
}
void Bullet::DeleteBullet
{
Bullet *next;
Bullet *last;
next = this->next_bullet;
last = this->last_bullet;

// skip current bullet, then delete
next->last_bullet = last;
last->next_bullet = next;
delete [] this;
}

This probably won''t work (so don''t compile it! ), but it might get the idea across... And then during the gameloop you''d have to create some kind of loop that walks through each bullet and does its ai. Look up a linked list tutorial in the Articles section if you don''t understand them...
Goodluck!
-Jesse


| <a href="http://www.angelfire.com/games4/parsec/index.html">The Hitchhiker''s Guide to Programming</a> |
"That is not dead which can eternal lie,
And with strange aeons even death may die."
-H.P. Lovecraft


The linked list is a good idea, just remember DO NOT call the ADDBULLET and DELETEBULLET functions in your main game loop. New and Delete as well as malloc and free are expensive time wise, and should never be done durring game play.
0

Share this post


Link to post
Share on other sites