Results 1 to 18 of 18

Thread: Help In Angles

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Posts
    80

    Help In Angles

    Hello, i need some help in a small game i am doing.

    it involves ships moving in angles.

    i have some problems , and if someone is available i will be more than happy if he contacts me in my icq : 38901147

    thank you.


    email : [email protected]
    Got It , Roger And Out

  2. #2
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    well for angles:

    you have an angle your ship is going to move at let's say it 50 degree.

    now you need to know how far it moves on the x and the y axis so you go like
    xmovement = velocity * cos(angle)
    ymovement = velocity * sin(angle)

    now since VB uses radians you need to convert the angle first before typing this in as vbcode
    To convert take the angle times Pi and devide it by 180.
    Sanity is a full time job

    Puh das war harter Stoff!

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Posts
    80
    First of all thanks for replying.

    this i already know

    i need to know more about rotating the image itself to point 20 degs , for example that the y-axis ?

    i mean , if i press left and right the ship rotates in few degs

    i have the rotating fucn. but i dont understand it , and thus i have difficulties adjusting it to my own needs.
    Got It , Roger And Out

  4. #4
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    there is a good example on how to rotate a bitmap by angles on www.ur.co.nz
    but you could also use d3d to do it (it's even faster and easier)
    Sanity is a full time job

    Puh das war harter Stoff!

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Posts
    80
    hmm , in d3d , without math , just functions ?
    Got It , Roger And Out

  6. #6
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    hm well depending on how you do it a little bit of math to turn the polygon on which you draw your ship I guess, or the camera.
    Sanity is a full time job

    Puh das war harter Stoff!

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Posts
    80
    Here is a little exe in vb that i wrote , it concludes anything i know about rotating .

    few problems :

    1. holes in the rotated picture , i know there is another way to rotate so there wont be holes.

    2. speed are problamatic.


    3. when i give him x=x+veloicty*cos(angle) , its not excat , i want it to move in good angle . not sort of angle .
    Got It , Roger And Out

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Posts
    80
    The File
    Attached Files Attached Files
    Got It , Roger And Out

  9. #9
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    you probably put an integer value for the position since in the end it will be represented by an integer value (pixels) anyways, but that compromises any accuracy if you take many little steps so just use floats.
    Sanity is a full time job

    Puh das war harter Stoff!

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Posts
    80
    Sorry , but i didnt quite understood u.

    i use something like this x=100+fix(veiolicty*cos(angle))

    and for y as well with sin.


    and for the rotation i use

    x=point.x*cos(angle)-point.y*sin(angle)

    destx=100+fix(x)

    y=point.x*sin(angle)+point.y*cos(angle)

    desty=100+fix(y)
    Got It , Roger And Out

  11. #11
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    this does not seem to make a lot of sense to me:
    x=100+fix(veiolicty*cos(angle))

    I think it should be like
    x=x+fix(velocity *cos(angle)) 'angle in radian

    that so it can move further not just be on one fixed place

    than I don't know why you do the fix, it will make it inaccurate go like:
    dim x as double

    x=x+velocity*cos(angle)

    this will be way more accurate.
    Sanity is a full time job

    Puh das war harter Stoff!

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Posts
    80
    First of all

    i do x=x+fix(veiolicty*cos(angle)

    not +100

    i dont know why i wrote +100 , but about the fix , i must use it , how can i write a pixel at 581.34278427 ?

    it should be a fix number , or am i mistaken ?
    Got It , Roger And Out

  13. #13
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    the pixel yeah but not the position
    you need to keep the exact position because you keep on calculating with it it get very inaccurate if you round it.
    so fix it to draw but not the position itself
    get it?
    if not tell me I will explain better after getting some sleep it is 4:20 in the morning and I am drunk....
    Sanity is a full time job

    Puh das war harter Stoff!

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Posts
    80
    oh , ofcourse , i didnt see i do fix in the calculate instead of the setpixel function

    yeah,

    well , just one more question , i wanted to check Frame Rate

    so i did every 18.2 ticks (with gettickcount) a counter that shows how many time the main loop was running

    and i got 3 , how could this be ? , its very smooth and cant be just 3 frames ?

    i did some precalc like sin and cos tables and any math , and i just have 2 bitblt and 2 mul functions

    ?
    Got It , Roger And Out

  15. #15
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    I never did an precalc on sin and cos does it speed things up a lot?
    well you check it all 18 ticks?
    1000 ticks is one second, so just put some kind of sub into you loop going like this

    VB Code:
    1. function fps() as string
    2. static framesPS
    3. static lasttic as long
    4. static count as long
    5.  count = count
    6.  if lassttick < GetTickCout then
    7.    lasttick = GetTickCount +1000
    8.    framesPS = count
    9.    count = 0
    10.  endif
    11.  fps = str(framesPS)
    12. end function

    (you can do it much better than that here but that should work and give you fps that don't change around all the time but only once a second.... (and than they will be more consistent too))
    Sanity is a full time job

    Puh das war harter Stoff!

  16. #16
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    well here some little recent discussion about Frames per second measurement...
    you can go for Zaeis version too, or use the code I gave in the other thread, it does not use statics, but it is in the loop so it's kind of the same thing. (one var less though because I made it a function and not just write to a global var this time)

    Frames Per Second
    Sanity is a full time job

    Puh das war harter Stoff!

  17. #17

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Posts
    80
    Thats ok , thanks .
    i thought one second is 18.2

    but if its 1000 its about 120fps

    now for my last question , if u dont mind , and its about tcp/ip connection.

    i want that the remote computer will update data in real time

    i mean , if the remote computer moved , i want the local computer to know without lag , which means i need to transmirt X,Y of the sprite about 30-40 times a second , is it possible ?
    Got It , Roger And Out

  18. #18
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    yeah it should be possible over network (internet also) but you will never be safe from lagging... you should ask in a new thread to get more qualified answers! (I really know crap about networking.)
    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
  •  



Click Here to Expand Forum to Full Width