Gun Help

Talk about making games.

Gun Help

Postby Scorpion50o1 » Thu Jul 29, 2010 12:34 am

OK this version has Pistol, Machine Gun, ShotGun, and BattleRifle
[single shot, full auto, spread single shot, and burst]
Attachments
gunz.zip
Yeah Burst now
(227.93 KiB) Downloaded 65 times
Last edited by Scorpion50o1 on Sun Aug 01, 2010 2:46 am, edited 2 times in total.
OMG IM SO BORED <(^^)> (>^^)> (>^^)>
92% of teens have moved on to rap. If you are part of the 8% who still listen to real music, copy and paste this into your signature.
User avatar
Scorpion50o1
 
Posts: 246
Joined: Fri Apr 17, 2009 1:07 am
Location: TX
Score: 8 Give a positive score

Re: Gun Help

Postby krenisis » Thu Jul 29, 2010 2:54 am

Ok this is pretty good...its different from the tutorial i did but the shotgun is great coding. I think this is a good way but I do it differently. You should upload thec data file with the arial.ttf font. Since Iam a vetaran I just loaded up the font but most people will not know how to do that. Goodwork!!!
Tutorial Database for all beginners click this link
viewtopic.php?f=4&t=8680
krenisis
 
Posts: 606
Joined: Sat Jul 25, 2009 3:27 pm
Score: 51 Give a positive score

Re: Gun Help

Postby DST » Thu Jul 29, 2010 7:14 am

Okay this is not the best way to go about this. 1st, you should have only one bullet actor. Then make two global variables, shotangle and shotvelocity. Then, on bullet>createactor>

Code: Select all
angle=shotangle;
directional_velocity=shotvelocity;


And on the event to shoot bullets (which should be machine gun's event, not other's):
Code: Select all
shotangle=0;
shotvelocity=15;
CreateActor("bullet", "bullet", "no parent", "no path", width/2, 0, false); 


shotangle is a global variable, and each bullet will perform it's createactor as it's made, so you can then change shotangle and make new bullets, and they will all start with the last value shotangle was set to before their createactor() was called.
The width/2 is the width of the creator actor, in this case, gun. This will make bullets appear at (gun center+half gun width), or, at the far right side of gun.

To simplify, do this:

Code: Select all
int i;
int tempangle=5;   //the angle between shots
for(i=0; i<5; i++){      //do this 5 times
shotangle(10-(i*tempangle);  //(tempangle is 5, so shot 0 = 10; shot 1= 5; shot 2=0; shot3=355, shot4=350;)
shotvelocity=15;
CreateActor("bullet", "bullet", "no parent", "no path", width/2, 0, false);
}


Now if you want to make a different bullet animation, or speed (rockets may move slower), you only have one createactor() line to edit. Note that this loop code fires all five bullets at once. It could shoot 1000 bullets at once and the code wouldn't get any longer.


The way you have it, with all those bullet actors, is that each object that bullets collide with will need an event for every single bullet. Editing that is way too hard. You should definitely have only one bullet actor.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest