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

Username:   Password: 
 RegisterRegister   
 program help plz
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Weapon X




PostPosted: Mon Apr 11, 2005 12:04 pm   Post subject: program help plz

here is my code. i dont know whts wrong, can someone help plz? i know i have to put in a cls but i dont know where


code:
import "DanSprite.tu"
setscreen ("graphics,nobuttonbar")
setscreen ("offscreenonly")
var x, y : int %var for the first sprite
var x2, y2 : int %var for the second sprite
var x3, y3 : int %var for the 1st ovals quadents
var x4, y4 : int %var for the 2nd ovals quadents
var nx3, ny3, nx4, ny4 : int := 1 %vars for the chage in qroadents
var s : int := 10 %var for the size of the ovals
var chars : array char of boolean


x := 1
y := 1
x2 := 100
y2 := 100
var pic : int := DanSprite.newPic (x, y, "slime1.jpg")
DanSprite.setMode(pic,DanSprite.MERGE)
var pic2 : int := DanSprite.newPic (x2, y2, "slime2.jpg")
DanSprite.setMode(pic2,DanSprite.MERGE)
x3 := Rand.Int (1, 100) %set the x quadent for the 1st oval
y3 := Rand.Int (1, 100) %set the y quadent for the 1st oval
x4 := Rand.Int (1, 100) %set the x quadent for the 2nd oval
y4 := Rand.Int (1, 100) %set the y quadent for the 2nd oval

%main loop
loop
    if Input.hasch then
        Input.KeyDown (chars)
        if chars (KEY_UP_ARROW) then
            y += 10
            DanSprite.movePic (x, y, pic) 
            end if
        if chars (KEY_RIGHT_ARROW) then
            x += 10
            DanSprite.movePic (x, y, pic)
            end if
        if chars (KEY_LEFT_ARROW) then
            x -= 10
            DanSprite.movePic (x, y, pic) 
        end if
        if chars (KEY_DOWN_ARROW) then
            y -= 10
            DanSprite.movePic (x, y, pic)
        end if
       
        if chars ('w') then
            y2 += 10
            DanSprite.movePic (x2, y2, pic2)
        end if
        if chars ('d') then
            x2 += 10
            DanSprite.movePic (x2, y2, pic2)
        end if
        if chars ('a') then
            x2 -= 10
            DanSprite.movePic (x2, y2, pic2)
        end if
        if chars ('s') then
            y2 -= 10
            DanSprite.movePic (x2, y2, pic2)
        end if

 end if
   
    drawfilloval (x3, y3, s, s, red) %draws the 1st oval
    drawfilloval (x4, y4, s, s, green) %draws the 2nd one   
   
     View.Update     


   
    %check to see if oval gose off the screen
    %for oval 1
   
    if x3 <= 0 then %check to see if it gose off the bottom
        nx3 := 1 %chages the direction
    elsif y3 <= 0 then %check to see if it gose off to the left
        ny3 := 1 %chages the direction
    end if

    if x3 >= maxx then %check to see if it gose off the top
        nx3 := - 1 %chages the direction
    elsif y3 >= maxy then %check to see if it gose off to the right
        ny3 := - 1 %chages the direction
    end if

 
    %check to see if oval gose off the screen
    %for oval 2
   
    if x4 <= 0 then %check to see if it gose off the bottom
        nx4 := 1 %chages the direction
    elsif y4 <= 0 then %check to see if it gose off to the left
        ny4 := 1 %chages the direction
    end if

    if x4 >= maxx then %check to see if it gose off the top
        nx4 := - 1 %chages the direction
    elsif y4 >= maxy then %check to see if it gose off to the right
        ny4 := - 1 %chages the direction
    end if



    %this if checks to see if the ovals have hit each other
    if x3 + s > x2 - s and x2 - s < x2 + s and y2 + s > y2 - s and y2 - s < y2 +
            s then
       



        %chages the direction of all the ovals
        nx3 := nx3 * - 1
        ny3 := ny3 * - 1
        nx4 := nx4 * - 1
        ny4 := ny4 * - 1
    end if

    %this part adds the chage in qroadents to the
    %quradents and makes the ovals move
    x3 += nx3
    y3 += ny3
    x4 += nx4
    y4 += ny4

    delay (0)
     
end loop



net2.jpg
 Description:
 Filesize:  30.72 KB
 Viewed:  1069 Time(s)

net2.jpg



net1.jpg
 Description:
 Filesize:  30.69 KB
 Viewed:  1068 Time(s)

net1.jpg



slime2.jpg
 Description:
 Filesize:  11.56 KB
 Viewed:  1068 Time(s)

slime2.jpg



slime1.jpg
 Description:
 Filesize:  11.56 KB
 Viewed:  1068 Time(s)

slime1.jpg


Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon Apr 11, 2005 1:21 pm   Post subject: (No subject)

just after the View.Update is where cls usually goes
jamonathin




PostPosted: Mon Apr 11, 2005 1:34 pm   Post subject: (No subject)

Next time just put everything into one zip file (or rar). No one's going to want to download each, then save all of them individually.
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: