Im making a shooting game, and need some help?

Posted 26 March 2011 - 07:02 PM

Hi, im trying to make a shooting game where your character is always in the center of the screen (so basicly, the map scrolls AROUND you as you move around) and he looks at where your cursor is, and shoots to where your cursor is.

I've just been having some problem I wouldnt have a single clue how to fix, and i have tried Googling it and asking on other forums already many times, so I came here.

Anyway, I'm having mainly two problems;

The first, of course, is the one where Im not sure how I would get my character to look at my cursor. So far, the logic behind that is basicly

If X > imgYourCharacter.Left and Y > imgYourCharacter.Top then
imgYourCharacter.Image =
End if

And the empty entry after image would be the sprite that corresponds with your character looking diagonally up and right. So that would take a lot of coding to do a 16-directional sprite set, but that isnt the problem. The problem is that the character has a gun. He needs to be able to use it. So what I DO NOT know at all how to do would be how to make it so that when the user clicks, the gun sound clip plays, a timer is activated (changing the animation of the sprite to make it shoot) and most importantly, (I already know how to make a sound clip play and how to activate a timer) make it so that a image (the bullet) travels from the character and in the cursors direction (until it gets off-map, in which case, it will restore itself to the "False" position.

The second most important bit of code I would never be able to fgure out is; the map is obviously many more time larger than the character, and the character is only supposed to be able to see a portion of the map at a time. So my question is, how would I make it so that the screen only shows a fixed amount of the map at a time, and how do I make it so that when one of the WASD keys is pressed (I know that its something like;

If KeyAscii = 97 then
Etc etc occurs
End if

the map SCROLLS in the direction the player is moving.

Thank you everyone! I know this is a hard request, but I really have tried searching for many things, and I having found any solutions...

Re: Im making a shooting game, and need some help?

Posted 28 March 2011 - 04:43 PM

smohd, on 28 March 2011 - 02:53 PM, said:

You may need this snippet here and here. then you can use to decide the picture to display!

Thanks, that helps me, but how could I make it so that this code makes the bullet, gives it a name, places it on the form, and shoots it towards the cursor direction? I'm missing two parts mainly; the part where it places itself in the correct place of the form (in front of the gun of the soldier) and where it shoots itself towards the cursor direction.

Public Class Bullet
Dim newPictureBox As New PictureBox
Dim Bulletname as String
Dim i As Integer
Randomize 93
i = (Rnd() * 99999)
Bulletname = "B" & i
'This randomizing part is so that I can avoid arrays and give the bullet a temporary name until I delete it
'The top and the left are excluded since I dont know where to put them to make it appear infront of the gun :S
Bulletname.Image = Image.FromFile("C:\BG\Bullet.png")
Bulletname.Visible = True
Bulletname.Width = 100
Bulletname.Height = 50
Bulletname.Tag = 3
Controls.Add(newPictureBox)
'here is where I would place the code im missing :S
End Class

Thank you!

btw, I found a really good example of my game; the game "Alien Swarm" is a good representation of what i want my game to be like (just the look and move mechanics, and I'm not sure if you're ALWAYS in the centre of the screen in Alien Swarm, but the shooting part is definetely what i want to replicate.

Re: Im making a shooting game, and need some help?

Posted 28 March 2011 - 05:03 PM

Ok, then you need another image for the bullet or you may use zero or dot.(something like bullet)
Then you move it from the point you are to the point the mouse clicks.
There is a good tutorial talking about how to draw line from one point to another where a mouse click, unfortunately I forget where it was you can go and look for it, it will help you to move the bullet to the point

Re: Im making a shooting game, and need some help?

Posted 28 March 2011 - 05:12 PM

smohd, on 28 March 2011 - 05:03 PM, said:

Ok, then you need another image for the bullet or you may use zero or dot.(something like bullet)
Then you move it from the point you are to the point the mouse clicks.
There is a good tutorial talking about how to draw line from one point to another where a mouse click, unfortunately I forget where it was you can go and look for it, it will help you to move the bullet to the point

What do you mean I need another image for the bullet? The class creates the image doesnt it?

Re: Im making a shooting game, and need some help?

Posted 28 March 2011 - 07:09 PM

Okay, so I remembered that i dont need to know how to draw, i just need to know how to make a new object, start its position at some point (the bullet is the object, the starting position is infront of the gun), use a timer to move it closer to the position of where the cursor was (the position is saved in a string/integer/whatever they're saved in nowadays ) each time the timer is called. But what Im not getting is what would I tell the timer to do so that the position of the bullet moves closer to the position where the cursor was?

Is there some kind of "Move 1 pixel towards this position" kind of function built in? S: