Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Speed Math Tweek for 3D Game
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
frank26080115




PostPosted: Sun Dec 10, 2006 11:41 pm   Post subject: Speed Math Tweek for 3D Game

I made this game after playing "the missile game 3d" on albino black sheep

the flash one is here
http://www.albinoblacksheep.com/games/missilegame3d

the one i made is similar and simpler, but the gates appear to slow down as they get closer, i tried to tweek it as much as possible, but if sometimes it gets jerky and stuff and i'm out of ideas, i marked out the stuff that is responsible for the obstacle gates movement and size

can you help me tweek the equations

code:
var winID : int
var mx, my, mbutton : int
var xoff, yoff : int
var width1, height1 : int := 500
var rx1, lx1, ty1, by1 : real
var rx2, lx2, ty2, by2 : real
var rx3, lx3, ty3, by3 : real
var rx4, lx4, ty4, by4 : real
var obsx, obsy, rad1 : real
var ang1 : int := 0
var ang2 : int := ang1 + 270
var anginc : int := 10
var rotdir : int := 1
%%% variables for the gates %%%
var dividedinto : real := 20
var divfac1 : real := 0.125
var divfacacc1 : real := 0.125
var divfacacc2 : real := 0.125
%%% variables for the gates %%%
var score1 : int := 0
var font : int
font := Font.New ("serif:12")

winID := Window.Open ("position:center;center,graphics:" + intstr (width1) + ";" + intstr (height1) + ",nobuttonbar")
loop
    setscreen ("offscreenonly")
    loop
        % mouse
        Mouse.Where (mx, my, mbutton)
        mx := maxx - mx
        my := maxy - my
        if mx >= width1 then
            mx := width1
        elsif mx <= 0 then
            mx := 0
        end if
        if my >= width1 then
            my := width1
        elsif my <= 0 then
            my := 0
        end if
        if mx = (width1 div 2) then
            xoff := 0
        else
            xoff := mx - (width1 div 2)
        end if
        if my = (width1 div 2) then
            yoff := 0
        else
            yoff := my - (width1 div 2)
        end if
        % variable area 1
        rx1 := ((width1 div 2) + xoff) + 355
        ty1 := ((width1 div 2) + yoff) + 355
        lx1 := ((width1 div 2) + xoff) - 355
        by1 := ((width1 div 2) + yoff) - 355
        rx2 := ((width1 div 2) + xoff div 70) + 5
        ty2 := ((width1 div 2) + yoff div 70) + 5
        lx2 := ((width1 div 2) + xoff div 70) - 5
        by2 := ((width1 div 2) + yoff div 70) - 5
        rx3 := rx1 + (rx1 - (width1 div 2)) * 2
        ty3 := ty1 + (ty1 - (width1 div 2)) * 2
        lx3 := lx1 - ((width1 div 2) - lx1) * 2
        by3 := by1 - ((width1 div 2) - by1) * 2
        %%% gate movement (finds position and radius) %%%
        obsx := 250 + xoff div dividedinto * divfac1
        obsy := 250 + yoff div dividedinto * divfac1
        rad1 := 500 div dividedinto * divfac1
        %%% gate movement (finds position and radius) %%%
        % draw area 1
        Draw.Line ((width1 div 2), (width1 div 2), round (rx1 + 145), ((width1 div 2) + yoff), red)
        Draw.Line ((width1 div 2), (width1 div 2), round (lx1 - 145), ((width1 div 2) + yoff), red)
        Draw.Line ((width1 div 2), (width1 div 2), ((width1 div 2) + xoff), round (ty1 + 145), red)
        Draw.Line ((width1 div 2), (width1 div 2), ((width1 div 2) + xoff), round (by1 - 145), red)
        Draw.Line ((width1 div 2), (width1 div 2), round (rx1), round (ty1), red)
        Draw.Line ((width1 div 2), (width1 div 2), round (rx1), round (by1), red)
        Draw.Line ((width1 div 2), (width1 div 2), round (lx1), round (ty1), red)
        Draw.Line ((width1 div 2), (width1 div 2), round (lx1), round (by1), red)
        Draw.Line (round (rx3), round (ty3), round (rx1), round (ty1), red)
        Draw.Line (round (rx3), round (by3), round (rx1), round (by1), red)
        Draw.Line (round (lx3), round (ty3), round (lx1), round (ty1), red)
        Draw.Line (round (lx3), round (by3), round (lx1), round (by1), red)
        Draw.FillOval (round ((((rx2 - lx2) div 2) + lx2)), round ((((ty2 - by2) div 2) + by2)), (7), (7), white)
        Draw.Oval (round ((((rx2 - lx2) div 2) + lx2)), round ((((ty2 - by2) div 2) + by2)), (9), (9), white)
        Draw.Oval (round ((((rx2 - lx2) div 2) + lx2)), round ((((ty2 - by2) div 2) + by2)), (11), (11), white)
        Draw.Oval (round ((((rx2 - lx2) div 2) + lx2)), round ((((ty2 - by2) div 2) + by2)), (14), (14), white)
        Draw.Oval (round ((((rx2 - lx2) div 2) + lx2)), round ((((ty2 - by2) div 2) + by2)), (18), (18), white)
        Draw.Oval (round ((((rx2 - lx2) div 2) + lx2)), round ((((ty2 - by2) div 2) + by2)), (23), (23), white)
        % Draw.Oval ((((rx2 - lx2) div 2) + lx2), (((ty2 - by2) div 2) + by2), (14), (14), red)
        %%% Drawing Gate %%%
        Draw.FillArc (round (obsx), round (obsy), round (rad1), round (rad1), ang1, ang1 + ang2, grey)
        Draw.FillOval (round (obsx), round (obsy), round (rad1 div 3), round (rad1 div 3), grey)
        Draw.Oval (round (obsx), round (obsy), round (rad1), round (rad1), black)
        %%% Drawing Gate %%%
        %Draw.Line ((width1 div 2), (width1 div 2), ((width1 div 2) + xoff), ((width1 div 2) + yoff), brightgreen)
        Draw.Text ("score: " + intstr (score1), 5, 5, font, black)
        % variable area 2
        %%% acceleration addition %%%
        divfacacc1 += divfacacc2
        divfac1 += divfacacc1
        %%% acceleration addition %%%
        if rotdir = 1 then
            ang1 += anginc
        elsif rotdir = 2 then
            ang1 -= anginc
        end if
        if divfac1 > dividedinto + 25 then
            %%% variable reset %%%
            divfac1 := 0.125
            divfacacc1 := 0.125
            ang1 := Rand.Int (0, 360)
            anginc := Rand.Int (0, 10)
            rotdir := Rand.Int (1, 2)
            %%% variable reset %%%
        elsif divfac1 > dividedinto + 10 and whatdotcolor (maxx div 2, maxy div 2) = grey then
            exit
        end if
        if ang1 > 360 then
            ang1 := 0
        end if
        score1 += 1
        % end of frame
        delay (100)
        View.Update
        cls
    end loop
    cls
    setscreen ("graphic")
    put "you lose"
    View.Update
    delay (1000)
    divfac1 := 0.125
    divfacacc1 := 0.125
    ang1 := Rand.Int (0, 360)
    anginc := Rand.Int (0, 10)
    rotdir := Rand.Int (1, 2)
    score1 := 0
end loop
Sponsor
Sponsor
Sponsor
sponsor
Hackmaster




PostPosted: Mon Dec 11, 2006 12:46 pm   Post subject: (No subject)

Good Stuff, Frank! again, you made a pretty sweet program. you are definally ramping up to be a really active, contributing member on this site! keep up the good work.

By the way.. it does seem pretty jerky up near the front. as it turns out, it's almost impossible to lose up near the front. good randomization though!

keep it up!
frank26080115




PostPosted: Tue Dec 12, 2006 12:42 am   Post subject: (No subject)

its not that its jerky, its that it appears to slow down, so i'm asking everyone to play around with the numbers until somebody gets a realistic look

i'm moving on the harder/easier stuff, PBASIC !! check out my main focus these days http://franksjunk.thespudmall.com/sumobot/
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: