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

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




PostPosted: Sun May 07, 2006 6:09 pm   Post subject: Building killer

here is a game i just made...didnt take very long to make...but all u have to do is shoot the guy in the building, and shoot the bombs that are falling, and if the bombs hit the ground u lose a point, u start with 5....i used arrays and whatdotcolot!! nad procedures


have fun


code:

setscreen ("offscreenonly;nobuttonbar;graphics:1200;950;position:center;center;title:Shoot 'Em")
var x, y, b : int
var kills : int := 0
var oldbutton : int
var health : int := 5
b := 0
%%
proc aimer
    drawoval (x, y, 310, 310, 12)
    drawoval (x, y, 309, 309, 12)
    drawoval (x, y, 308, 308, 12)
    drawoval (x, y, 307, 307, 12)
    drawoval (x, y, 306, 306, 12)
    drawoval (x, y, 305, 305, 12)
    drawoval (x, y, 304, 304, 12)
    drawoval (x, y, 303, 303, 12)
    drawoval (x, y, 309, 309, 12)
    Draw.ThickLine (x, y + 300, x, y - 300, 10, 12)
    Draw.ThickLine (x - 300, y, x + 300, y, 10, 12)
end aimer
%%
proc building
    %Building
    drawfillbox (80, 0, 1120, 900, 4)
    %Building
    %First Window
    drawfillbox (100, 860, 350, 640, yellow)
    %First Window
    %Second Window
    drawfillbox (360, 860, 610, 640, yellow)
    %Second Window
    %Third Window
    drawfillbox (620, 860, 850, 640, yellow)
    %Third Window
    %Fourth Window
    drawfillbox (860, 860, 1100, 640, yellow)
    %Fourth Window
    %First Window
    drawfillbox (100, 600, 350, 380, yellow)
    %First Window
    %Second Window
    drawfillbox (360, 600, 610, 380, yellow)
    %Second Window
    %Third Window
    drawfillbox (620, 600, 850, 380, yellow)
    %Third Window
    %Fourth Window
    drawfillbox (860, 600, 1100, 380, yellow)
    %Fourth Window
    %First Window
    drawfillbox (100, 340, 350, 120, yellow)
    %First Window
    %Second Window
    drawfillbox (360, 340, 610, 120, yellow)
    %Second Window
    %Third Window
    drawfillbox (620, 340, 850, 120, yellow)
    %Third Window
    %Fourth Window
    drawfillbox (860, 340, 1100, 120, yellow)
    %Fourth Window
end building
%%
proc features
    %Door
    drawfillbox (120, 700, 180, 640, 15)
    drawfilloval (170, 660, 5, 5, 7)
    %Door
    %Door2
    drawfillbox (400, 440, 460, 380, 15)
    drawfilloval (450, 400, 5, 5, 7)
    %Door2

    %Door3
    drawfillbox (900, 180, 960, 120, 15)
    drawfilloval (950, 140, 5, 5, 7)
    %Door3
end features
%%
type bombs :
    record
        bombx : int
        bomby : int
    end record
var bomb : array 1 .. 4 of bombs
for i : 1 .. 1
    randint (bomb (i).bombx, 100, 900)
    randint (bomb (i).bomby, 130, 700)
end for
for q : 1 .. 2
    randint (bomb (q).bombx, 100, 900)
    randint (bomb (q).bomby, 130, 700)
end for
%%
%People
type peoples :
    record
        peoplex : int
        peopley : int
        peoplex2 : int
        peopley2 : int
        peoplex3 : int
        peopley3 : int
        dir : int
    end record
var people : array 1 .. 5 of peoples
for i : 1 .. 5
    randint (people (i).peoplex, 120, 1070)
    randint (people (i).peopley, 670, 670)
    randint (people (i).peoplex2, 120, 1070)
    randint (people (i).peopley2, 410, 410)
    randint (people (i).peoplex3, 120, 1070)
    randint (people (i).peopley3, 150, 150)
    randint (people (i).dir, -4, 4)
end for
%%
%Main Loop
loop
    colorback (7)
    oldbutton := b
    mousewhere (x, y, b)
    cls
    building
    features
    %%Top Building
    for i : 1 .. 5
        drawfillarc (people (i).peoplex, people (i).peopley, 20, 20, 20, -10, 6)
        drawline (people (i).peoplex, people (i).peopley - 30, people (i).peoplex + 0, people (i).peopley - 20, 7)
        drawfilloval (people (i).peoplex + 5, people (i).peopley + 10, 3, 3, 0)
        people (i).peoplex += people (i).dir
        if people (i).peoplex < 120 then
            randint (people (i).peoplex, 120, 1070)
            randint (people (i).peopley, 670, 670)
        end if
        if people (i).peoplex > 1070 then
            randint (people (i).peoplex, 120, 1070)
            randint (people (i).peopley, 670, 670)
        end if
        if whatdotcolor (x, y) = 6 and b = 1 and oldbutton = 0 then
            randint (people (i).peoplex, 120, 1070)
            randint (people (i).peopley, 670, 670)
            kills += 1
        end if
    end for
    %%Top Building
    %Middle Building
    for i : 1 .. 3
        drawfillarc (people (i).peoplex2, people (i).peopley2, 20, 20, 20, -10, blue)
        drawline (people (i).peoplex2, people (i).peopley2 - 30, people (i).peoplex2 + 0, people (i).peopley2 - 20, 7)
        drawfilloval (people (i).peoplex2 + 5, people (i).peopley2 + 10, 3, 3, 0)
        people (i).peoplex2 += people (i).dir
        if people (i).peoplex2 < 120 then
            randint (people (i).peoplex2, 120, 1070)
            randint (people (i).peopley2, 410, 410)
        end if
        if people (i).peoplex2 > 1070 then
            randint (people (i).peoplex2, 120, 1070)
            randint (people (i).peopley2, 410, 410)
        end if
        if whatdotcolor (x, y) = blue and b = 1 and oldbutton = 0 then
            randint (people (i).peoplex2, 120, 1070)
            randint (people (i).peopley2, 410, 410)
            kills += 1
        end if
    end for
    %Middle Building
    %Last Building
    for i : 1 .. 4
        drawfillarc (people (i).peoplex3, people (i).peopley3, 20, 20, 20, -10, 5)
        drawline (people (i).peoplex3, people (i).peopley3 - 30, people (i).peoplex3 + 0, people (i).peopley3 - 20, 7)
        drawfilloval (people (i).peoplex3 + 5, people (i).peopley3 + 10, 3, 3, 0)
        people (i).peoplex3 += people (i).dir
        if people (i).peoplex3 < 120 then
            randint (people (i).peoplex3, 120, 1070)
            randint (people (i).peopley3, 150, 150)
        end if
        if people (i).peoplex3 > 1070 then
            randint (people (i).peoplex3, 120, 1070)
            randint (people (i).peopley3, 150, 150)
        end if
        if whatdotcolor (x, y) = 5 and b = 1 and oldbutton = 0 then
            randint (people (i).peoplex3, 120, 1070)
            randint (people (i).peopley3, 150, 150)
            kills += 1
        end if
    end for
    %Last Building
    %%
    %Bombs
    if kills >= 20 then
        for i : 1 .. 1
            drawfilloval (bomb (i).bombx, bomb (i).bomby, 10, 10, green)
            bomb (i).bomby -= 1
            if whatdotcolor (x, y) = green and b = 1 and oldbutton = 0 then
                randint (bomb (i).bombx, 100, 900)
                randint (bomb (i).bomby, 130, 700)
            end if
            if kills >= 50 then
                for q : 1 .. 2
                    drawfilloval (bomb (q).bombx, bomb (q).bomby, 10, 10, 56)
                    bomb (q).bomby -= 1
                    if whatdotcolor (x, y) = 56 and b = 1 and oldbutton = 0 then
                        randint (bomb (q).bombx, 100, 900)
                        randint (bomb (q).bomby, 130, 700)
                    end if
                    if bomb (q).bomby < 0 then
                        randint (bomb (q).bombx, 100, 900)
                        randint (bomb (q).bomby, 130, 700)
                        health -= 1
                    end if
                end for
            end if
            if kills >= 60 then
                bomb (i).bomby -= 2
            end if
            if bomb (i).bomby < 0 then
                randint (bomb (i).bombx, 100, 900)
                randint (bomb (i).bomby, 130, 700)
                health -= 1
            end if
        end for
    end if
    if health <= 0 then
        cls
        exit
    end if
    %Bombs
    %%
    aimer
    %%Writing
    color (yellow)
    put "Position X: ", x ..
    locate (2, 1)
    put "Position Y: ", y ..
    drawbox (0, 1000, 150, 914, yellow)
    %%
    %%
    locate (1, 18)
    put "Objective:" ..
    locate (2, 18)
    put "Kill All Of The People" ..
    drawbox (168, 1000, 390, 914, yellow)
    %%
    locate (1, 42)
    put "Money:" ..
    locate (2, 42)
    put kills ..
    drawbox (408, 1000, 490, 914, yellow)
    %%
    locate (1, 52)
    put "Buildings Health: "
    locate (2, 52)
    put health, "%" ..
    drawbox (508, 1000, 710, 914, yellow)
    %%
    locate (4, 50)
    colorback (red)
    put " The Downtown Office" ..
    %%
    %%Writing
    delay (15)
    View.Update
end loop
%Main Loop
loop
    colorback (7)
    color (0)
    locate (1, 1)
    put "You Lose!"
    put "Total Kills: ", kills
    View.Update
end loop
Sponsor
Sponsor
Sponsor
sponsor
jamonathin




PostPosted: Sun May 07, 2006 8:31 pm   Post subject: (No subject)

Interesting game, but this is excellent proof as to why whatdotcolor collision detection sucks.

code:

for i : 1 .. 5
     . . .
        if whatdotcolor (x, y) = 6 and b = 1 and oldbutton = 0 then
            randint (people (i).peoplex, 120, 1070)
            randint (people (i).peopley, 670, 670)
            kills += 1
        end if
end for


Do you wonder why half of the people teleport when u kill someone, or mathematically i should say. .
i - 5 people teleport


You haven't even updated the screen, so yes i did hit that guy and yes 1 is added to my kills, but my whatdotcolor is STILL 6! making everyone else in that for loop teleport somewhere else.

Try different methods for this type of game, and maybe shrink it a bit Wink.
Andy




PostPosted: Sun May 07, 2006 11:22 pm   Post subject: (No subject)

jamonathin wrote:
this is excellent proof as to why whatdotcolor ... sucks.


hey there.. watch it! Cool
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: