Results 1 to 14 of 14

Thread: angle shooting

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Posts
    15

    angle shooting

    i am a beginer . i want a very very simple program to shoot an object(shape) for me on the form with a certain angle .

  2. #2
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    you mean move and object?
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Posts
    15
    you know what i mean . like the old gorilla game . but not that complicated!!!!!!!!!!!
    i want a very very simple one.
    i want to give an angle (and maybe a velocity) and after pressing a button the object (shape) will move across the form according to the calculations . and don't worry , i am good in physics.
    please , give me the simplest way.
    thankyou

  4. #4
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    to move the object from one point to another

    VB Code:
    1. Slope = (EndY - StartY) / (EndX - StartX)
    2.  
    3. For X = StartX To EndX
    4.     Object.Left = X
    5.     Object.Top = X * Slope
    6. Next X

    im not so good in working with angles, but i think i can show you later....eating right now
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  5. #5

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Posts
    15
    please help we with angle shooting (moving an object ).
    well,is there anyone else to help. does anyone know how to code such a program. in the simplest way for a beginer!
    thank you

  6. #6
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Use a picture box and a timer. Put a picture of the thing you want to move in the picture box. Then set the interval of the timer to 50 or something and enabled to true.

    In the timer event write something like

    VB Code:
    1. Picture1.left = picture1.left + 1

  7. #7

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Posts
    15
    thanks, but i know about moving an object . i want to learn about moving an object with an angle .
    here's the program :
    i have a command button and a shape in my form along with a text box .after adding an amount in the textbox and clicking the button, the shape is shot and flies through the form. actually the amount that goes in the textbox is the angle that the shape should be shot at. something like the old gorilla game but not that complicated!!!!!very very simple.
    thankx again.

  8. #8
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    VB is using Rad and not degrees. So first you have to calculate the angle in PI. Then you will have to calculate the X and Y vectors. I suppose you have to enter the velocity somewhere in you app too. So then you can calculate the X and Y speed.

    In the timer event add the X speed to the left property and the Y component in the top property...

  9. #9
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    ...If you didn't get that, look here for a start...
    Attached Files Attached Files

  10. #10

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Posts
    15
    thank you so much. it really worked in the simplest way.!!!!
    thankx again.
    uhhhhhhhhhhhh.
    is there anyway to tell the shape to come down after it travels a certain distance.(like a parabola path) . can you help me again in the simplest way.

  11. #11
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    OK, this is pure physics. I hope you get this....


    and don't worry , i am good in physics.
    I hope Newton is a great friend of yours

    At first we want talk about wind and air. Only pure physics. The formulas for "diagonally throws" is:

    V0x = V0 *cosA I used this formula in my app.
    V0y = V0 *sinA I used this formula in my app.

    Vx = V0x The Speed in the X way, wont change with no air...
    Vy = V0y - g*t The speed in the Y way, will change with t and g.

    X = V0x*t
    Y = V0y*t - 0,5*g*t^2

    g = 9.81m/s^2

    So you have to calculate a new X and Y every time the ball is moving. (that would be in the timer event) and then move the ball.

    If you have problems understanding this, post again. And I will see what I can do...but try for your selves first...
    Last edited by NoteMe; Dec 4th, 2002 at 06:32 AM.

  12. #12
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    OK, I admit that I'm bored....so here you have an example...
    Attached Files Attached Files

  13. #13
    Junior Member
    Join Date
    Dec 2002
    Posts
    19
    thankyou so much , i was looking for such a great help in a very simple way for months! the code was excellent !

  14. #14
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by mnbvcxz
    thankyou so much , i was looking for such a great help in a very simple way for months! the code was excellent !

    The code isn't that great...it's just a little physics. But I'm glad someone found it usefull. So just post again if you or anyone else have more questions to ask...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width