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

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




PostPosted: Wed Jun 09, 2004 12:40 pm   Post subject: Real and int

How can I make this prg work. I have a real int and a int in the same Pic.Draw. Help

code:

View.Set ("offscreenonly")
var x, y : int
x := 0
y := 0
var keys : array char of boolean
var jump := false %boolean. since it's declared as false turing knows its boolean
var x1, y1, vy : real %vy = velocity in the y plane.  aka, the upwards velocity of the player.
x1 := 0
y1 := 0
const gravity := 0.1
var size := 35
var enemy : int := Pic.FileNew ("enemy1.bmp")
var player : int := Pic.FileNew ("player.jpg")
drawline (0, 4, maxx, 4, 17)
loop
    cls
    drawline (0, 4, maxx, 4, 17)
    Input.KeyDown (keys)
    if keys (KEY_UP_ARROW) and not jump then %"and not jump" is the same as "and jump = false"
        jump := true
        vy := 4
    end if
    if jump then %"if jump then" is the same as "if jump = true then"
        y1 += vy % same as y := y + vy
        vy -= gravity % same as vy := vy - gravity
        if y1 <= 5 then
            jump := false
        end if
    end if
    View.Set ("offscreenonly") %Stops the pictures from flickering
    %Pic.ScreenLoad ("player.jpg", round (x1), round (y1 + 5), picCopy)
    Pic.Draw (player, round (x1), round (y1 + 5), picCopy)
    drawbox (399, 25, 430, 50, 17)
    Pic.Draw (enemy, 400, 30, picCopy)
    delay (10)
    %Makes the Player Move.
    var chars : array char of boolean
    Input.KeyDown (chars)
    if chars (KEY_RIGHT_ARROW) then
        x1 += 3
    end if
    if chars (KEY_LEFT_ARROW) then
        x1 -= 3
    end if
    if chars (KEY_UP_ARROW) then
        y1 += 3
    end if
    if chars (KEY_DOWN_ARROW) then
        y1 -= 3
    end if
    if chars (' ') then
        var bullet := Pic.FileNew ("bullet2.jpg")
        for x2 : x .. x + 50
            Pic.Draw (bullet, x1 + x2, y1 + 30, picMerge)
            Pic.Draw (player, round (x1), round (y1 + 5), picCopy)
            View.Update
        end for
    end if
    View.Update
end loop

thanx
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Wed Jun 09, 2004 2:38 pm   Post subject: (No subject)

you round() the real values just like you did in every other Pic.Draw command Confused
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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: