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

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




PostPosted: Tue Jun 06, 2006 4:16 pm   Post subject: flexible

ok i wanna benable ot shot and have multiple bullets come otu leik a machine gun my code is as follows:

code:

setscreen ("offscreenonly")
var x, y : int := 100
var chars : array char of boolean
var Bullet : boolean := false
var bullet : flexible array 1 .. 1 of
    record
        bulletx : int
        bullety : int
    end record
for i : 1 .. 1
    bullet (i).bulletx := x
    bullet (i).bullety := y
end for

loop
    Input.KeyDown (chars)
    cls
    drawfilloval (x, y, 12, 12, 7)




    for i : 1 .. 1
        if chars (KEY_ENTER) then

            drawfilloval (bullet (i).bulletx, bullet (i).bullety, 4, 4, 12)
            Bullet := true
        end if

        if Bullet = true then
            bullet (i).bulletx += 1
        end if
    end for


    View.Update
end loop




y is the ball dissapeared? y aernt there more than one bullet?
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Tue Jun 06, 2006 4:20 pm   Post subject: (No subject)

there isnt more than one bullet because you only ever have a maximum upper bound to your array of 1, so you therefore need a new statement to increase the upper bounds of your array and add another bullet to the screen, also, you dont get another bullet because the x value of your bullet is never reset to its original coordinate, causing it to be drawn further and further off the screen Very Happy
Clayton




PostPosted: Tue Jun 06, 2006 4:22 pm   Post subject: (No subject)

oops double post, but anyway,

in that second for loop (the one inside your main loop) you should have the upper bounds of the for be upper(arrayName) instead of a hardcoded 1 because you are only accessing the data for the first bullet in your array and you can therefore not draw anymore than the first bullet
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: