Ergebnis 1 bis 4 von 4
  1. #1
    Multimedialist
    Registriert seit
    17.04.2003
    Beiträge
    64.659
    Hi there..

    okay: i wanted to try to make a car game...
    the problem is not really the programming, i'm not much into math anymore
    (a long time ago, in a galaxy far far away...)

    i want that if i press the UP key it should drive UP..
    and if i press LEFT OR RIGHT it should make an circle...

    my script is:

    global xAlt
    global yAlt
    global pSpr
    global pAngle


    on beginsprite me
    pSpr = sprite(me.spritenum)
    pAngle = 0
    xAlt= sprite(me. spritenum).locH
    yAlt= sprite(me. spritenum).locV
    end

    on enterframe me

    --down
    if keypressed (125) then
    pSpr.locV = pSpr.locV + 5
    end if
    --up
    if keypressed (126) then

    pSpr.locv = pSpr.locV - 5
    end if
    --left
    if keypressed (123) then
    winkelneu()
    pSpr.locH = pSpr.locH - 5
    end if
    --right
    winkelneu()
    if keypressed (124) then
    pSpr.locH = pSpr.locH + 5
    end if
    pSpr.rotation = pAngle
    end


    on winkelneu
    pAngle = atan(pSpr.locH-xAlt, pSpr.locV-yAlt)/PI*-180
    end


    and its turning around like a drunken sailor...
    can anyone help me???
    thanks a lot..
    joergi

  2. #2
    Multimedialist
    Registriert seit
    17.04.2003
    Beiträge
    64.659
    This demo will give a start-

    http://www.jmckell.com/directionvelo.html

    -McKell

  3. #3
    Multimedialist
    Registriert seit
    17.04.2003
    Beiträge
    64.659
    Okay, i have now perfected it..
    the old one had a problem:
    when you have 2 cars, and you give both care the same script (only with other keys of course) the case isn't working perfect anymore...
    so i changed it, and the best: its now TIME BASED, not frame based.
    it means, it will works on every computer in the self speed...


    property sp
    property x
    property y
    property tCar
    on beginsprite me
    sp = sprite(me.spritenum)
    x = sp.loch -- position bestimmen
    y = sp.locv -- position bestimmen
    tCar = 0
    timeout ("rot").new (1, #timeOutHandler, sprite(me.spritenum))

    end

    on timeOutHandler me


    -- Tastaturabrage
    -- vorwaerts
    if keypressed(126) then speed = 2

    -- links
    if keypressed(123) then tCar = tCar +.2

    -- rechts
    if keypressed(124) then tCar = tCar -.2

    --set velocity, increment position
    xVelo = cos(tCar) * speed
    yVelo = -sin(tCar) * speed
    x = x + xVelo
    y = y + yVelo

    --set sprite properties
    sp.loch = x
    sp.locv = y
    sp.rotation = -tCar * 180 / pi --convert to degrees
    end

  4. #4
    Multimedialist
    Registriert seit
    17.04.2003
    Beiträge
    64.659
    ok,thanks a lot
    "jmckell" <webforumsuser@macromedia.com>
    ??????:b5r22r$p63$1@forums.macromedia.com...
    This demo will give a start-

    http://www.jmckell.com/directionvelo.html

    -McKell

Ähnliche Themen

  1. 3D Driving Game
    Von Dolbarian im Forum Adobe Director Usenet Archiv
    Antworten: 3
    Letzter Beitrag: 18.03.2006, 20:49
  2. Collision detection for driving game
    Von mk0505 im Forum Adobe Director Usenet Archiv
    Antworten: 5
    Letzter Beitrag: 13.02.2006, 15:32
  3. Driving Game
    Von Spaz im Forum Adobe Director Usenet Archiv
    Antworten: 1
    Letzter Beitrag: 02.02.2005, 20:00
  4. New shockwave 3d driving combat game
    Von AndyN im Forum Adobe Director Usenet Archiv
    Antworten: 2
    Letzter Beitrag: 25.10.2004, 11:00
  5. Driving me Bananas
    Von Alida im Forum Adobe Director Usenet Archiv
    Antworten: 2
    Letzter Beitrag: 29.09.2004, 19:00
 
 
Letzte Artikel