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

Username:   Password: 
 RegisterRegister   
 Can you beat 60?
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
upthescale




PostPosted: Sat Apr 01, 2006 10:50 pm   Post subject: Can you beat 60?

I can't upload music, so just take out the music files in the code
thanks give me hate also cuz u always do it

ps. the program will be glitchy it is because u dont have the music, so take it out and it will b fine
Sponsor
Sponsor
Sponsor
sponsor
cool dude




PostPosted: Sun Apr 02, 2006 9:38 am   Post subject: (No subject)

thats pretty hard to beat. has some flickering even when i take out the mucsic and your instructions go off the screen. also if i hold my mouse over the button but not click it will select that button. overall good game! Smile
Delos




PostPosted: Sun Apr 02, 2006 10:17 am   Post subject: (No subject)

Why must you use processes? Really, your code would be so much more efficient if you used procedures and functions instead. As it stands, it really needs a lot of work.
You'll notice that in segments like "money2" you have a lot of repetitive code. This could easily be fixed by using procedures. Read the tuts and improve on what you already have.
Your collision detection is buggy. I had several blocks move right through the paddle despite them aligning perfectly.
Also, why does one lose a life for going off the screen? Why don't you just restrict the movement of the paddle if you don't want people moving it there?
Again, using breaks. This leads on from the processes comment. Once you get yourself some procedures in there, you won't need breaks anymore and things will look far prettier.
MysticVegeta




PostPosted: Sun Apr 02, 2006 2:49 pm   Post subject: (No subject)

Here is a really simple version of your game using procs and fcns and records instead of using processes, as yuo can see, it is clearly more efficient in several ways, study the code and implement the methods in further projects that you do, because running smoothly is a really important focus of a programming game project. I have named the procs and vars long so that you could understand whats going on inside of them, again, this is a really simple version, I am sure other people here can come up with a highly detailed and 100X better version that this.
code:
setscreen ("offscreenonly")
var sc := 0
var x, y, b : int
var lives := 5
var changeInSize := 0
var scoresPoss : array 1 .. 6 of int := init (10, 20, 30, 40, 50, 60)
var cols : array 1 .. 2 of int := init (brightred, black)
type enemy :
    record
        x : int
        y : int
        col : int
        size : int
        goDownRate : int
    end record
var ens : array 1 .. 3 of enemy

proc randAll
    for s : 1 .. 3
        ens (s).x := Rand.Int (0, maxx)
        ens (s).y := Rand.Int (400, 650)
        ens (s).col := cols (Rand.Int (1, upper (cols)))
        ens (s).size := Rand.Int (10 + changeInSize, 15 + changeInSize)
        ens (s).goDownRate := 1
    end for
end randAll

proc moveAndDrawEnsAndDisplayScore
    cls
    for s : 1 .. 3
        ens (s).y -= ens (s).goDownRate
        drawfillbox (ens (s).x, ens (s).y, ens (s).x + ens (s).size, ens (s).y + ens (s).size, ens (s).col)
    end for
    locate (1, 1)
    put "SCORE: ", sc
    locate (2, 1)
    put "LIVES: ", lives
end moveAndDrawEnsAndDisplayScore

fcn enemiesAreOffScreen : boolean
    for s : 1 .. 3
        if ens (s).y > 10 then
            result false
        end if
    end for
    result true
end enemiesAreOffScreen

proc checkCollisionAndTakeAction (x : int, y : int)
    for s : 1 .. 3
        if (ens (s).x >= x and ens (s).x <= x + 70 and ens (s).y >= 20 and ens (s).y <= 30) then
            if ens (s).col = brightred then
                lives -= 1
            else
                sc += 1
            end if
            ens (s).y := -100
        end if
    end for
end checkCollisionAndTakeAction

randAll
loop
    mousewhere (x, y, b)
    if enemiesAreOffScreen then
        randAll
    end if
    for s : 1 .. 6
        if scoresPoss (s) = sc then
            changeInSize := s
        end if
    end for
    moveAndDrawEnsAndDisplayScore
    drawfillbox (x, 20, x + 70, 30, blue)
    checkCollisionAndTakeAction (x, y)
    View.Update
    if sc >= 60 then
        put "YOU WIN!"
        exit
    elsif lives < 0 then
        put "YOU LOSE!"
        exit
    end if
end loop


Just increase the goDownRate in the randAll Procedure to increase their speed of going down Smile I made it small so that I could debug the problems
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  [ 4 Posts ]
Jump to:   


Style:  
Search: