14 Replies - 6477 Views - Last Post: 28 March 2011 - 07:09 PM Rate Topic: -----

#1 elemein  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 26-March 11

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...

Is This A Good Question/Topic? 0
  • +

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

#2 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

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

Posted 28 March 2011 - 02:53 PM

You may need this snippet here and here. then you can use to decide the picture to display!
Was This Post Helpful? 1
  • +
  • -

#3 elemein  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 26-March 11

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

Posted 28 March 2011 - 04:43 PM

View Postsmohd, 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.

Thanks!
Was This Post Helpful? 0
  • +
  • -

#4 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

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
Was This Post Helpful? 1
  • +
  • -

#5 elemein  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 26-March 11

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

Posted 28 March 2011 - 05:12 PM

View Postsmohd, 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?

Ah, right, do you remember if that tutorial was on DIC? :S
Was This Post Helpful? 0
  • +
  • -

#6 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

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

Posted 28 March 2011 - 05:23 PM

Yah, it is here.
Was This Post Helpful? 1
  • +
  • -

#7 elemein  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 26-March 11

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

Posted 28 March 2011 - 05:25 PM

View Postsmohd, on 28 March 2011 - 05:23 PM, said:

Yah, it is here.


Oh thanks, ill take a look for it after dinner ^^ Thanks for your help!
Was This Post Helpful? 0
  • +
  • -

#8 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

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

Posted 28 March 2011 - 05:28 PM

Dinner?! oh we are in 3:28 AM here.
Just joking

This post has been edited by smohd: 28 March 2011 - 05:31 PM

Was This Post Helpful? 0
  • +
  • -

#9 elemein  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 26-March 11

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

Posted 28 March 2011 - 06:04 PM

View Postsmohd, on 28 March 2011 - 05:28 PM, said:

Dinner?! oh we are in 3:28 AM here.
Just joking


Could you please tell me which one of them is the tutorial if either of them is?

http://www.dreaminco...bberband-shape/

or

http://www.dreaminco...th-mouse-in-vb/

Sorry, I dont really understand either of them, but if I knew which one was right, I might be able to try to understand it better
Was This Post Helpful? 0
  • +
  • -

#10 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

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

Posted 28 March 2011 - 06:10 PM

This is cool, you can understand and it can help here, but not the one which I pointed to before, but nice for starting!

Unless it is not a tutorial any more!!

This post has been edited by smohd: 28 March 2011 - 06:11 PM

Was This Post Helpful? 0
  • +
  • -

#11 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

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

Posted 28 March 2011 - 06:16 PM

You can see this video on youtube also
Was This Post Helpful? 0
  • +
  • -

#12 elemein  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 26-March 11

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

Posted 28 March 2011 - 06:19 PM

View Postsmohd, on 28 March 2011 - 06:16 PM, said:

You can see this video on youtube also


Right, Ill take a look at that video, but can you tell me whats wrong here? :S
       Dim mPosition As String 
        mPosition = Cursor.Position
        Label1.Text = mPosition



It says mPosition cannot be saved as a String. If thats the case, what can it be saved as?
Was This Post Helpful? 0
  • +
  • -

#13 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

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

Posted 28 March 2011 - 06:28 PM

Cursor.position takes the coordinate x,y and is saved as point data type not string. you need to get .x or .y for position to get the number (Cursor.position.X), another video
Was This Post Helpful? 1
  • +
  • -

#14 elemein  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 26-March 11

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

Posted 28 March 2011 - 06:31 PM

View Postsmohd, on 28 March 2011 - 06:28 PM, said:

Cursor.position takes the coordinate x,y and is saved as point data type not string. you need to get .x or .y for position to get the number (Cursor.position.X), another video


When I try to save it as Data, it doesnt recognize that as a format for some reason

Also, when I do this;


        Dim bullet As New PictureBox
        bullet.Image = ("C:\Desktop\Pictures\Bullet")
        bullet.Left = Cursor.Position.X
        bullet.Top = Cursor.Position.Y
        bullet.Height = 100
        bullet.Width = 1000
        bullet.Tag = 5
        Label1.Text = bullet.Tag



Just to see if I can get the mouse position part right, it gives me this error;

"Value of type 'String' cannot be converted to 'System.Drawing.Image'."

I didnt even save anything as a string. Whats up with that?

Ill take a look at that other video after im done with the first one : P
Was This Post Helpful? 0
  • +
  • -

#15 elemein  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 26-March 11

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:

        Dim bullet As New Label
        bullet.Text = "Bullet"
        bullet.Left = Cursor.Position.X 
        bullet.Top = Cursor.Position.Y
        bullet.Height = 100
        bullet.Width = 1000
        bullet.Tag = 5
        Label1.Text = bullet.Tag
        bullet.ForeColor = Color.Black



And why this doesnt work is a total mystery to me. It shows the tag in the label (i did this to see if the bullet was actually made) but the label itself doesnt show up... Whys that? S:

This post has been edited by elemein: 28 March 2011 - 07:11 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1