|
-
Dec 10th, 2002, 12:15 PM
#1
Thread Starter
Junior Member
Bullets from a sprite?
Im making an action game in a 2d environment with 2d characters. The charcter(man), holding a gun, is all one image or sprite. So I use the page flipping method in directdraw to animated him walking. Im having problem as how would I make him shoot a bullet from the tip of the nozzle of the gun. Because the gun keeps moving and is not in the same place everytime. Is there a way to get its x,y coordinate?
-
Dec 10th, 2002, 12:27 PM
#2
I'm not sure if it is an easy way to do that. But if you want to do it you could always record wich "picture" is showing and hardcode the X,Y coordinates for the gun and add the left and top coordinates of your man....
-
Dec 10th, 2002, 12:47 PM
#3
Addicted Member
Use an array of points that matches the animation frames, similar to what NoteMe posted. Hopefully the gun still points in a direction that makes sense to shot at. If the gun points down in one frame and you let him shoot then, it will look pretty silly if the bullet flies out horizontally.
-
Dec 10th, 2002, 12:48 PM
#4
Originally posted by Machaira
Use an array of points that matches the animation frames, similar to what NoteMe posted. Hopefully the gun still points in a direction that makes sense to shot at. If the gun points down in one frame and you let him shoot then, it will look pretty silly if the bullet flies out horizontally.
...hehehe...lol....yes...that would look silly...
-
Dec 10th, 2002, 01:18 PM
#5
Thread Starter
Junior Member
well......thats tideous work but looks like i have no choice..thanks for the advice!
-
Dec 10th, 2002, 01:22 PM
#6
Fanatic Member
hmmm
Assuming I understand what you mean..
You want a man to be able to rotate around (360 degrees or just u/d/r/l...)
Anyways, my suggestion is to have a variable keeping track of his rotation, and to use that angle to move bullet... so:
VB Code:
sub shoot
BulletDir = AngleOfPerson:BulletX = XofPerson':lalalalalla
'ok so MAYBE im leaving a bit out...
end sub
sub move(Ref X,Ref Y,Ref speed,Ref angle)
'All the above should be referenced, I'm not sure if it's written correctly.
X = X + Speed * Sin(Angle)
Y = Y + Speed * Cos(Angle)
End sub
That move code is INCREDIBLY usefull, it lets you move things in all directions, by changing the angle variable (0-360, 361 = 1 duh)
Don't pay attention to this signature, it's contradictory.
-
Dec 10th, 2002, 01:24 PM
#7
Re: hmmm
Originally posted by alkatran
Assuming I understand what you mean..
You want a man to be able to rotate around (360 degrees or just u/d/r/l...)
Anyways, my suggestion is to have a variable keeping track of his rotation, and to use that angle to move bullet... so:
VB Code:
sub shoot
BulletDir = AngleOfPerson:BulletX = XofPerson':lalalalalla
'ok so MAYBE im leaving a bit out...
end sub
sub move(Ref X,Ref Y,Ref speed,Ref angle)
'All the above should be referenced, I'm not sure if it's written correctly.
X = X + Speed * Sin(Angle)
Y = Y + Speed * Cos(Angle)
End sub
That move code is INCREDIBLY usefull, it lets you move things in all directions, by changing the angle variable (0-360, 361 = 1 duh)
If that was what you ment..then I think I and Machaira may have miss understodd you...are you rotating 360degrees or is it a one man walking in 2D game (left right)...???
-
Dec 10th, 2002, 01:36 PM
#8
Thread Starter
Junior Member
MY game is supposed 2d, ie. moving left and right only
-
Dec 10th, 2002, 01:38 PM
#9
Then I think alkatran missunderstood...and you would have to do it the hard way..
-
Dec 10th, 2002, 01:43 PM
#10
Fanatic Member
Well
Damn, stupid inferior games!!
But anyways, make a frame where he shoots, problem solved, always in same spot.
Don't pay attention to this signature, it's contradictory.
-
Dec 10th, 2002, 01:46 PM
#11
Re: Well
Originally posted by alkatran
Damn, stupid inferior games!!
But anyways, make a frame where he shoots, problem solved, always in same spot.
Thats the best idea I have heard all day....hheheeh....
-
Dec 11th, 2002, 11:50 AM
#12
Frenzied Member
basically I am with alcatran, why would he shoot on every walking frame... I doubt you actually shoot standing on the tips of one foot 
well what I wanted to say is that you might want to check out Statemachines for that
a good explanation can be found on www.ur.co.nz
Sanity is a full time job
Puh das war harter Stoff!
-
Dec 11th, 2002, 12:35 PM
#13
Frenzied Member
Re: hmmm
Originally posted by raoul85
MY game is supposed 2d, ie. moving left and right only
Well, that would be 1d....moving in only one direction...
Originally posted by alkatran
VB Code:
X = X + Speed * Sin(Angle)
Y = Y + Speed * Cos(Angle)
shouldnt it be like this?
VB Code:
X = X + Speed * Sin(Angle * (Pi / 180))
Y = Y + Speed * Cos(Angle * (Pi / 180))
-
Dec 11th, 2002, 02:02 PM
#14
Frenzied Member
well only if he has his angle stored in degree what wouldn't really help to much
Sanity is a full time job
Puh das war harter Stoff!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|