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

Username:   Password: 
 RegisterRegister   
 SHOOTING
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mynameisbob




PostPosted: Sun Jun 20, 2004 2:47 pm   Post subject: SHOOTING

I need help making the player shoot. I can do 45 degree and 90 degree shots but how do i do the ones in between?

Heres the code:
code:
View.Set ("graphics:200;250,nobuttonbar")
var xmouse, ymouse, button : int
var xp := 60.0
var yp := 60.0
var xbg, ybg : int := 0

%draw the player
proc player
    Draw.ThickLine (round (xp) + 9, round (yp) + 3, round (xp) + 10, round (yp), 3, 22) %left hand
    Draw.ThickLine (round (xp) + 4, round (yp) - 3, round (xp) + 22, round (yp) - 4, 5, darkgrey) %gun
    drawbox (round (xp) + 4, round (yp) - 6, round (xp) + 24, round (yp) - 2, black) %gun outline
    Draw.ThickLine (round (xp) + 8, round (yp) - 8, round (xp) + 10, round (yp) - 5, 3, 22) %right hand
    Draw.ThickLine (round (xp), round (yp) + 8, round (xp) + 9, round (yp) + 3, 4, brightblue) %left arm
    Draw.FillOval (round (xp) + 3, round (yp) - 9, 6, 3, brightblue) %right arm
    Draw.FillOval (round (xp), round (yp), 6, 11, 22) %body
    Draw.Oval (round (xp), round (yp), 6, 11, black) %body outine
    Draw.FillOval (round (xp) - 1, round (yp), 5, 3, 91) %head
    Draw.Oval (round (xp) - 1, round (yp), 5, 4, black) %head outline
    Draw.Line (round (xp) + 1, round (yp) - 3, round (xp) + 1, round (yp) + 3, black)
    drawfill (round (xp), round (yp), blue, black)
end player
player
var copy1 := Pic.New (50, 45, 82, 75)
var pic1 : int := Pic.Rotate (copy1, 90, -1, -1)
Pic.Free (copy1)

%create the rotated player pictures
var picRot : array 0 .. 35 of int
for rep : 0 .. 35
    picRot (rep) := Pic.Rotate (pic1, rep * 10, Pic.Width (pic1) div 2 + 7, Pic.Height (pic1) div 2 + 5)
end for
var pictmp := picRot (0)
var counter := 0

var keys : array char of boolean
proc control
    if keys (KEY_UP_ARROW) then
        xp += cosd ((counter mod 36) * 10 + 90) * 5
        yp += sind ((counter mod 36) * 10 + 90) * 5
    end if
    if keys (KEY_DOWN_ARROW) then
        xp -= cosd ((counter mod 36) * 10 + 90) * 5
        yp -= sind ((counter mod 36) * 10 + 90) * 5
    end if
    if keys (KEY_LEFT_ARROW) then
        counter += 1
        pictmp := picRot (counter mod 36)
    end if
    if keys (KEY_RIGHT_ARROW) then
        counter -= 1
        pictmp := picRot (counter mod 36)
    end if
end control

proc boundry
    if xp <= 35 then
        xp := 36
        xbg += 3
    elsif xp >= 120 then
        xp := 119
        xbg -= 3
    elsif yp <= 35 then
        yp := 36
        ybg += 3
    elsif yp >= 120 then
        yp := 119
        ybg -= 3
    end if
end boundry


setscreen ("offscreenonly")
loop
    cls
    colourback (black)
    mousewhere (xmouse, ymouse, button)
    Input.KeyDown (keys)
    boundry
    drawfillbox (xbg,ybg,xbg+640,ybg+480,grey)
    drawfilloval (xbg+70,ybg+100,10,10,green)
    control
    Pic.Draw (pictmp, round (xp), round (yp + 50), picMerge)
    delay (50)
    View.Update
end loop
Sponsor
Sponsor
Sponsor
sponsor
SuperGenius




PostPosted: Sun Jun 20, 2004 3:18 pm   Post subject: (No subject)

you could look at the trig functions in turing. version 4.05 includes the tan function left out of previous versions i think.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: