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

Username:   Password: 
 RegisterRegister   
 array fun
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh pageAdd this topic to your bookmarks (CTRL-D) View next topic
Author Message
upthescale




PostPosted: Sat May 06, 2006 11:35 am   Post subject: array fun

ok,i learned arrays and whatdotc olor, so here is an odd program....left click to get points on the, and riht click to randomzize colors...now this mgiht seem weird but im just learnign so i was expermienting...god arrays are soo cool


code:

setscreen ("offscreenonly;graphics:1200;800;position:center;center;nobuttonbar;nocursor")
var x, y, b : int
var score : int := 0
type people :
    record
        x : int
        y : int
        col : int
    end record
var bodies : array 1 .. 60 of people
for i : 1 .. 60
    randint (bodies (i).x, 1, 900)
    randint (bodies (i).y, 400, 800)
    randint (bodies (i).col, 1, 99)
end for
loop
    mousewhere (x, y, b)
    colorback (100)
    cls
    for i : 1 .. 60
        drawfillarc (bodies (i).x, bodies (i).y, 30, 30, 34, 7, bodies (i).col)
        bodies (i).y -= 1
        if bodies (i).y < 78 then
            bodies (i).y += 3
            bodies (i).x += 3
        end if
        if bodies (i).x > 900 then
            bodies (i).y -= 3
        end if
        if bodies (i).y < -10 then
            randint (bodies (i).x, 1, 900)
            randint (bodies (i).y, 400, 800)
        end if
        if whatdotcolor (x, y) = bodies (i).col and b = 1 then
            randint (bodies (i).x, 1, 1200)
            randint (bodies (i).y, 400, 800)
            score += 1
        end if
        buttonchoose ("multibutton")
        var x2, y2, button, left, middle, right : int
        mousewhere (x2, y2, button)
        left := button mod 10
        middle := (button - left) mod 100
        right := button - middle - left
        if right = 100 then
            randint (bodies (i).col, 1, 255)
        end if
    end for
    locate (1, 1)
    put "Score ", score ..
    drawfillbox (0, 0, 900, 50, blue)
    drawline (1200, -50, 900, 50, 7)
    View.Update
end loop
 
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Sat May 06, 2006 6:45 pm   Post subject: (No subject)

k, a couple of things:
1) you can just hold down any button to get the (pac-men?), try and find a way to fix that

2)try and get into the habit of using commands such as Mouse.Where, or View.Set instead of mousewhere, or setscreen as it can help you get into OOP when you get there
 
upthescale




PostPosted: Sat May 06, 2006 7:56 pm   Post subject: (No subject)

wuts oop? like i no wut it stands for but what can u do with ity and why wud it matter? the styscreen i used to go Mouse.Where but i got lazy of the capitals and the period lol
 
Cervantes




PostPosted: Sat May 06, 2006 9:00 pm   Post subject: (No subject)

OOP is Object Oriented Programming. It's a programming paradigm, and a very powerful one, at that.

I agree that "Mouse.Where" should be used over "mousewhere", but the reason is closer to Modularity than OOP. With "Mouse.Where", you've got the "Where" method for the "Mouse" module. With mousewhere, you've got the "mousewhere", you've got this "mousewhere" method lumped somewhere nonsensicle, mixed into a huge pile of other functions that are totally unrelated.
 
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh pageAdd this topic to your bookmarks (CTRL-D) View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: