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

Username:   Password: 
 RegisterRegister   
 A small oval game
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
CrazyCanuck




PostPosted: Sat Jan 08, 2005 6:36 pm   Post subject: A small oval game

This is a minigame for my larger program, which I made in one day when I was bored in tech class. It's not meant to be really serious so I wouldn't judge it too much. Wink

Ovals come from random sides and move across the screen, increasing speed gradually with each. Unfortunately, it soon becomes utterly imposssible to grab them all! You lose when you miss 10.

Enjoy. Smile

-------------------------------------------------------------------
code:
procedure ovalgame
   
    View.Set ("offscreenonly")

 %All of the variables and such
 
    var reply : string
    var x, y, b : int := -1
    var c : int := 0
    var dx : int
    var dy:int
    var minimisscount : int := 0
    var minimiss : string
    var miniscorecount : int := 0
    var miniscore : string
    var miniwaveharder : int := 1
    var miniwavenumber : int := 1
    var fontmini : int
    var whatway : int

    fontmini := Font.New ("Times New Roman:10:Bold")


  loop

 %Resets the variables for the game

        minimisscount := 0
        miniscorecount := 0
        miniwaveharder := 1
        miniwavenumber := 1
        fontmini := Font.New ("Times New Roman:10:Bold")

%the mian loop of the game

        loop
            %randomly choses the direction of which the oval falls
            randint (whatway, 1, 4)
            %down
            if whatway = 1 then
                randint (dx, 1, 600)
                dy := 380
                %right
            elsif whatway = 2 then
                randint (dy, 1, 380)
                dx := 10
                %left
            elsif whatway = 3 then
                randint (dy, 1, 380)
                dx := 600
                %up
            elsif whatway = 4 then
                randint (dx, 1, 600)
                dy := 10
            end if

%Inner loop

            loop
                delay (50)
             
                %draws the score and misses and the oval
                miniscore := intstr (miniscorecount)
                minimiss := intstr (minimisscount)
                drawfillbox (0, 0, maxx, maxy, white)
                Font.Draw ("Hits", 8, 380, fontmini, brightred)
                Font.Draw (miniscore, 50, 380, fontmini, brightred)
                Font.Draw ("Misses", 8, 370, fontmini, brightred)
                Font.Draw (minimiss, 50, 370, fontmini, brightred)
                drawfilloval (dx, dy, 10, 10, blue)
                View.Update

%moves the oval about

                if whatway = 1 then
                    dy := dy - (2 + miniwaveharder)
                elsif whatway = 2 then
                    dx := dx + (2 + miniwaveharder)
                elsif whatway = 3 then
                    dx := dx - (2 + miniwaveharder)
                elsif whatway = 4 then
                    dy := dy + (2 + miniwaveharder)
                end if

                %tells if the mouse is on one of the blue ovals
%with the almighty whatdotcolour
                mousewhere (x, y, b)
                if whatdotcolor (x, y) = blue then
                    sound (500, 10)
                    Font.Draw ("Hit", dx + 10, dy + 20, fontmini, brightred)
                    View.Update
                    miniscorecount := miniscorecount + 1

                    miniwaveharder := miniwaveharder + 1
                    %-----------------------------------------%
                    %the oval leaves the screen
                elsif dy < 0 or dx < 0 or dy > 380 or dx > 600 then
                    Font.Draw ("Miss", dx + 10, dy + 20, fontmini, brightred)
                    View.Update
                    minimisscount := minimisscount + 1
                    miniwaveharder := miniwaveharder + 1
                end if
                exit when dy < 0 or dx < 0 or dy > 380 or dx > 600 or whatdotcolor (x, y) = blue

            end loop
            exit when minimisscount = 10
        end loop

%a synopsis of the gameplay

        fontmini := Font.New ("Times New Roman:30:Bold")
        drawfillbox (0, 0, maxx, maxy, white)
        Font.Draw ("You scored", 100, 200, fontmini, brightred)
        Font.Draw (miniscore, 300, 200, fontmini, brightred)
        Font.Draw ("hits", 375, 200, fontmini, brightred)

        Font.Draw ("Replay?", 300, 100, fontmini, brightred)
        View.Update
        get reply
        exit when reply not= "y"
    end loop
    cls
    Font.Draw ("Thanks for playing! :)", 100, 200, fontmini, brightred)
    View.Update
end ovalgame



ovalgame
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Sun Jan 09, 2005 12:09 am   Post subject: (No subject)

1)
Hello.

2)
Pls use [code] tags in the future. Or better yet, attatch a file.

3)
Ensure your code is bug free before posting it. Why did the game crass the first time I pressed F1?
'dy' had not been declared

4)
You havn't quite grasped the concept of procedures, or their use...but since you said not to judge your work too much, I'll stop there.

5)
Otherwise not a bad effort. Stick around, maybe you'll find you like it here.
CrazyCanuck




PostPosted: Sun Jan 09, 2005 10:57 am   Post subject: (No subject)

Its only a procedure because I cut it out of my larger program.
Embarassed
I'll add code tags now.

The bug edited as well. I guess I cut it out while chaging variable names

Thanks for your input. Smile
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: