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

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




PostPosted: Tue Mar 14, 2006 11:49 pm   Post subject: Game in the works

Yeah, you got a line with a ball moving across it. there is a box on the line. when the ball meets the inside of the box, click. if you click and teh ball isn';t in side the box then u lose...stil in progreess so give me ideas fer a newlevel, like the enxt level is it shows the box, and then it dissapears......









var count : int := 0 %Variables
var x, y, xx, yy, xxx, yyy, button, t, h : int %Variables
x := 10 %Co-ordinates
y := 200 %Co-ordinates
xx := 520 %Co-ordinates
yy := 190 %Co-ordinates
xxx := 500 %Co-ordinates
yyy := 210 %Co-ordinates
loop
drawfillbox (xx, yy, xxx, yyy, red) %Red Box
drawline (790, 200, 10, 200, 5) %Line
drawfilloval (x, y, 10, 10, 7) %Moving Ball
delay (20) %Moving Ball
drawfilloval (x, y, 10, 10, 0) %Moving Ball
x := x + 2 %Speed
mousewhere (t, h, button) %Mousewhere
if x >= 500 and x <= 520 and y >= 190 and y <= 210 and button = 1 then
exit %If ball is clicked while in the red, it will exit
elsif button = 1 then
drawfillbox (xx, yy, xxx, yyy, red) %Red Box
drawline (790, 200, 10, 200, 5) %Line
put "You lose!"
delay (1200)
break
end if %Ending the if
if x > 800 then %When ball goes out of screen, program says you lose
put "You lose!"
delay (1200)
break
end if
end loop
drawfillbox (xx, yy, xxx, yyy, red) %Red Box
drawline (790, 200, 10, 200, 5) %Line
put "Good!"
delay (900)
put ""
put "Next Level!"
delay (1200)
cls
x := 10 %Co-ordinates
y := 200 %Co-ordinates
xx := 520 %Co-ordinates
yy := 190 %Co-ordinates
xxx := 500 %Co-ordinates
yyy := 210 %Co-ordinates
loop
drawfillbox (xx, yy, xxx, yyy, red) %Red Box
drawline (790, 200, 10, 200, 5) %Line
drawfilloval (x, y, 10, 10, 7) %Moving Ball
delay (20) %Moving Ball
drawfilloval (x, y, 10, 10, 0) %Moving Ball
x := x + 4 %Speed
mousewhere (t, h, button) %Mousewhere
if x >= 500 and x <= 520 and y >= 190 and y <= 210 and button = 1 then
exit %If ball is clicked while in the red, it will exit
elsif button = 1 then
drawfillbox (xx, yy, xxx, yyy, red) %Red Box
drawline (790, 200, 10, 200, 5) %Line
put "You lose!"
delay (1200)
break
end if %Ending the if
if x > 800 then %When ball goes out of screen, program says you lose
put "You lose!"
delay (1200)
break
end if
end loop
drawfillbox (xx, yy, xxx, yyy, red) %Red Box
drawline (790, 200, 10, 200, 5) %Line
put "Good!"
delay (900)
put ""
put "Next Level!"
delay (1200)
cls
x := 10 %Co-ordinates
y := 200 %Co-ordinates
xx := 415 %Co-ordinates
yy := 195 %Co-ordinates
xxx := 425 %Co-ordinates
yyy := 205 %Co-ordinates
loop
drawfillbox (xx, yy, xxx, yyy, red) %Red Box
drawline (790, 200, 10, 200, 5) %Line
drawfilloval (x, y, 10, 10, 7) %Moving Ball
delay (20) %Moving Ball
drawfilloval (x, y, 10, 10, 0) %Moving Ball
x := x + 2 %Speed
mousewhere (t, h, button) %Mousewhere
if x >= 415 and x <= 425 and y >= 195 and y <= 205 and button = 1 then
exit %If ball is clicked while in the red, it will exit
elsif button = 1 then
drawfillbox (xx, yy, xxx, yyy, red) %Red Box
drawline (790, 200, 10, 200, 5) %Line
put "You lose!"
delay (1200)
break
end if %Ending the if
if x > 800 then %When ball goes out of screen, program says you lose
put "You lose!"
delay (1200)
break
end if
end loop
drawfillbox (xx, yy, xxx, yyy, red) %Red Box
drawline (790, 200, 10, 200, 5) %Line
put "Good!"
delay (900)
put ""
put "Next Level!"
delay (1200)
cls
x := 10 %Co-ordinates
y := 200 %Co-ordinates
xx := 100 %Co-ordinates
yy := 195 %Co-ordinates
xxx := 140 %Co-ordinates
yyy := 205 %Co-ordinates
loop
drawfillbox (xx, yy, xxx, yyy, red) %Red Box
drawline (790, 200, 10, 200, 5) %Line
drawfilloval (x, y, 10, 10, 7) %Moving Ball
delay (20) %Moving Ball
drawfilloval (x, y, 10, 10, 0) %Moving Ball
x := x + 3 %Speed
mousewhere (t, h, button) %Mousewhere
if x >= 100 and x <= 140 and y >= 195 and y <= 205 and button = 1 then
exit %If ball is clicked while in the red, it will exit
elsif button = 1 then
drawfillbox (xx, yy, xxx, yyy, red) %Red Box
drawline (790, 200, 10, 200, 5) %Line
put "You lose!"
delay (1200)
break
end if %Ending the if
if x > 800 then %When ball goes out of screen, program says you lose
put "You lose!"
delay (1200)
break
end if
end loop
drawfillbox (xx, yy, xxx, yyy, red) %Red Box
drawline (790, 200, 10, 200, 5) %Line
put "Good!"
delay (900)
put ""
put "Next Level!"
delay (1200)
cls
x := 10 %Co-ordinates
y := 200 %Co-ordinates
xx := 400 %Co-ordinates
yy := 195 %Co-ordinates
xxx := 420 %Co-ordinates
yyy := 205 %Co-ordinates
for g : 1 .. 120
drawfillbox (xx, yy, xxx, yyy, red) %Red Box
drawline (790, 200, 10, 200, 5) %Line
drawfilloval (x, y, 10, 10, 7) %Moving Ball
delay (20) %Moving Ball
drawfilloval (x, y, 10, 10, 0) %Moving Ball
x := x + 3 %Speed
mousewhere (t, h, button) %Mousewhere
if x >= 400 and x <= 420 and y >= 195 and y <= 205 and button = 1 then
exit %If ball is clicked while in the red, it will exit
elsif button = 1 then
drawfillbox (xx, yy, xxx, yyy, red) %Red Box
drawline (790, 200, 10, 200, 5) %Line
put "You lose!"
delay (1200)
break
end if %Ending the if
if x > 800 then %When ball goes out of screen, program says you lose
put "You lose!"
delay (1200)
break
end if
end for
for g : 1 .. 50
drawfillbox (xx, yy, xxx, yyy, red) %Red Box
drawline (790, 200, 10, 200, 5) %Line
drawfilloval (x, y, 10, 10, 7) %Moving Ball
delay (20) %Moving Ball
drawfilloval (x, y, 10, 10, 0) %Moving Ball
x := x - 3 %Speed
mousewhere (t, h, button) %Mousewhere
if x >= 400 and x <= 420 and y >= 195 and y <= 205 and button = 1 then
exit %If ball is clicked while in the red, it will exit
elsif button = 1 then
drawfillbox (xx, yy, xxx, yyy, red) %Red Box
drawline (790, 200, 10, 200, 5) %Line
put "You lose!"
delay (1200)
break
end if %Ending the if
if x > 800 then %When ball goes out of screen, program says you lose
put "You lose!"
delay (1200)
break
end if
end for
for g : 1 .. 120
drawfillbox (xx, yy, xxx, yyy, red) %Red Box
drawline (790, 200, 10, 200, 5) %Line
drawfilloval (x, y, 10, 10, 7) %Moving Ball
delay (20) %Moving Ball
drawfilloval (x, y, 10, 10, 0) %Moving Ball
x := x + 3 %Speed
mousewhere (t, h, button) %Mousewhere
if x >= 400 and x <= 420 and y >= 195 and y <= 205 and button = 1 then
exit %If ball is clicked while in the red, it will exit
elsif button = 1 then
drawfillbox (xx, yy, xxx, yyy, red) %Red Box
drawline (790, 200, 10, 200, 5) %Line
put "You lose!"
delay (1200)
break
end if %Ending the if
if x > 800 then %When ball goes out of screen, program says you lose
put "You lose!"
delay (1200)
break
end if
end for
drawfillbox (xx, yy, xxx, yyy, red) %Red Box
drawline (790, 200, 10, 200, 5) %Line
put "Good!"
delay (900)
put ""
put "Next Level!"
delay (1200)
cls
Sponsor
Sponsor
Sponsor
sponsor
TokenHerbz




PostPosted: Wed Mar 15, 2006 12:05 am   Post subject: (No subject)

i dont want to discourage you, but befor you make more levels, you should ponder on how to make your code better...

I Feel you have so much unnessesary code in there...

Further more so you know, the "break" command your useing isn't nessesarly for termination. Try useing "return".

As for more ideas, make the box move, and flash, thus if you click and its not there, you lose, and win if it is there, as long as the balls on top of it.

Your doing well though, keep trying...
jamonathin




PostPosted: Wed Mar 15, 2006 12:54 am   Post subject: (No subject)

First things first, please use code tags.
code:
[code]< insert code here >[/code]


Nextly, many things to touch upon; and I'll probabily miss a few.
Starting at the very top.

What is
code:
var x, y, xx, yy, xxx, yyy . . ?

in a few days will you be able to remember which one xx belongs to?
Since x and y belong to the ball, use something like
code:

var xBall,yBall : int
or
var bx,by : int

Something to signify it belongs to the ball, and the xx and xxx can be changed to
code:
x1, x2
or something different, try to avoid xx, yyy and so on.

Next, learn procedures. That way your program doesn't run from start to finish, it can basically "jump" from top to bottom and back, using specific procedures to do specific tasks, this way you can shorten your program and make it more efficient.

You don't need 'break' in your loops, for this, you can simply use 'exit', as used in 'exit when' statements.

Lastly for now, you could throw the values for the 'xx','yyy' values into an array, and keep count of the level using a simple variable.

For example, if the level is 4:
code:

var x1 : array 1 .. 5 of int := init (1, 2, 3, 4, 5)
var level : int := 4
put x1(level)

Kind of complicated right now, but read the Turing Walkthrough and look up arrays and procedures.

Your program isn't bad, dont get any of this wrong, but it's more important to look at what you did wrong, than what you did right. Keep up the good work Smile.
upthescale




PostPosted: Wed Mar 15, 2006 1:18 am   Post subject: (No subject)

sorry, but i took this cours and all i elarnedi n the coutrse wus if statments pretty much. i was never taught how to make things move, how to click on certain objects, idid that all on my own, so yeh the coding might be bad, but it still werks
Imm0rtal




PostPosted: Wed Mar 15, 2006 11:34 am   Post subject: (No subject)

That was very interesting. You should use variable names you can remember. Also use comments when showing source code.. example

code:

var xxx : int  %This is a coordinate for the ball


Comments make your life alot easier when programming huge projects. Other then that it seems like you know what your doing. Hope to see more.

As for things you could add.. maybe a background.. or a title screen. So it looks more User friendly Wink
upthescale




PostPosted: Wed Mar 15, 2006 12:12 pm   Post subject: (No subject)

i did use comments
upthescale




PostPosted: Wed Mar 15, 2006 12:19 pm   Post subject: (No subject)

code:
ok i am done the game and the intro is better......it's so long of a code, ho do i make it so that u can click on the file and save it or open it?
upthescale




PostPosted: Wed Mar 15, 2006 12:20 pm   Post subject: (No subject)

code:

var count : int := 0 %Variables
var x, y, xx, yy, xxx, yyy, button, t, h : int %Variables
var font2, x3, y3 : int %Variables
var ch : string (1) %Variables
var q, w, button1, font : int  %Variables
var answer : string %Variables
put "This game is called..."
delay (1200)
cls
x3 := 10
y3 := 300
for g : 1 .. 100
    font2 := Font.New ("chiller:60:bold")
    assert font2 > 0
    Font.Draw ("Enter", x3, y3, font2, brightblue)
    delay (15)
    cls
    font2 := Font.New ("chiller:60:bold")
    assert font2 > 0
    Font.Draw ("Enter ", x3, y3, font2, 0)
    y3 := y3 - 3
    x3 := x3 + 3
end for
x3 := 550
y3 := 400 
for g : 1 .. 120
    font2 := Font.New ("chiller:60:bold")
    assert font2 > 0
    Font.Draw ("The", x3, y3, font2, brightblue)
    delay (15)
    cls
    font2 := Font.New ("chiller:60:bold")
    assert font2 > 0
    Font.Draw ("The ", x3, y3, font2, 0)
    y3 := y3 - 3
    x3 := x3 - 3
end for
x3 := 10
y3 := 300
for g : 1 .. 120
    font2 := Font.New ("chiller:60:bold")
    assert font2 > 0
    Font.Draw ("Square", x3, y3, font2, brightblue)
    delay (15)
    cls
    font2 := Font.New ("chiller:60:bold")
    assert font2 > 0
    Font.Draw ("Square ", x3, y3, font2, 0)
    y3 := y3 - 3
    x3 := x3 + 3
end for
x3 := 100
y3 := 400
for g : 1 .. 120
    font2 := Font.New ("chiller:60:bold")
    assert font2 > 0
    Font.Draw ("Game", x3, y3, font2, brightblue)
    delay (15)
    cls
    font2 := Font.New ("chiller:60:bold")
    assert font2 > 0
    Font.Draw ("Game ", x3, y3, font2, 0)
    y3 := y3 - 3
    x3 := x3 + 3
end for
loop
    font := Font.New ("serif:20")
    Font.Draw ("If you know how to play, type in play", 126, 245, font, red)
    font := Font.New ("serif:20")
    Font.Draw ("If you want the rules, type in rules", 240, 205, font, red)
    get answer
    if answer = "rules" or answer = "Rules" then
        cls
        put "The instructions are simple...You have a ball on a line going across the line."
        put "There is also a square on that same line, located anywhere on that line..."
        put "When the ball meets the square/or the ball is touching the square..."
        put "Simply click on the mouse. Then you will win the level. Watch that you"
        put "don't click when the ball isn't touching the square, or you lose!"
        put ""
        put "Good luck!"
        put ""
        put "Hit a key to continue!"
        getch (ch)
        cls
    elsif answer = "Play" or answer = "play" then
        cls
        exit
    end if
end loop
x := 10 %Co-ordinates
y := 200 %Co-ordinates
xx := 520 %Co-ordinates
yy := 190 %Co-ordinates
xxx := 500 %Co-ordinates
yyy := 210 %Co-ordinates
loop
    drawfillbox (xx, yy, xxx, yyy, red) %Red Box
    drawline (790, 200, 10, 200, 5) %Line
    drawfilloval (x, y, 10, 10, 7) %Moving Ball
    delay (20) %Moving Ball
    drawfilloval (x, y, 10, 10, 0) %Moving Ball
    x := x + 2 %Speed
    mousewhere (t, h, button) %Mousewhere
    if x >= 500 and x <= 520 and y >= 190 and y <= 210 and button = 1 then
        exit %If ball is clicked while in the red, it will exit
    elsif button = 1 then
        drawfillbox (xx, yy, xxx, yyy, red)    %Red Box
        drawline (790, 200, 10, 200, 5) %Line
        put "You lose!"
        delay (1200)
        break
    end if     %Ending the if
    if x > 800 then %When ball goes out of screen, program says you lose
        put "You lose!"
        delay (1200)
        break
    end if
end loop
drawfillbox (xx, yy, xxx, yyy, red)     %Red Box
drawline (790, 200, 10, 200, 5)     %Line
put "Good!"
delay (900)
put ""
put "Next Level!"
delay (1200)
cls
x := 10 %Co-ordinates
y := 200 %Co-ordinates
xx := 520 %Co-ordinates
yy := 190 %Co-ordinates
xxx := 500 %Co-ordinates
yyy := 210 %Co-ordinates
loop
    drawfillbox (xx, yy, xxx, yyy, red) %Red Box
    drawline (790, 200, 10, 200, 5) %Line
    drawfilloval (x, y, 10, 10, 7) %Moving Ball
    delay (20) %Moving Ball
    drawfilloval (x, y, 10, 10, 0) %Moving Ball
    x := x + 4 %Speed
    mousewhere (t, h, button) %Mousewhere
    if x >= 500 and x <= 520 and y >= 190 and y <= 210 and button = 1 then
        exit %If ball is clicked while in the red, it will exit
    elsif button = 1 then
        drawfillbox (xx, yy, xxx, yyy, red)    %Red Box
        drawline (790, 200, 10, 200, 5) %Line
        put "You lose!"
        delay (1200)
        break
    end if     %Ending the if
    if x > 800 then %When ball goes out of screen, program says you lose
        put "You lose!"
        delay (1200)
        break
    end if
end loop
drawfillbox (xx, yy, xxx, yyy, red)     %Red Box
drawline (790, 200, 10, 200, 5)     %Line
put "Good!"
delay (900)
put ""
put "Next Level!"
delay (1200)
cls
x := 10 %Co-ordinates
y := 200 %Co-ordinates
xx := 415 %Co-ordinates
yy := 195 %Co-ordinates
xxx := 425 %Co-ordinates
yyy := 205 %Co-ordinates
loop
    drawfillbox (xx, yy, xxx, yyy, red) %Red Box
    drawline (790, 200, 10, 200, 5) %Line
    drawfilloval (x, y, 10, 10, 7) %Moving Ball
    delay (20) %Moving Ball
    drawfilloval (x, y, 10, 10, 0) %Moving Ball
    x := x + 2 %Speed
    mousewhere (t, h, button) %Mousewhere
    if x >= 415 and x <= 425 and y >= 195 and y <= 205 and button = 1 then
        exit %If ball is clicked while in the red, it will exit
    elsif button = 1 then
        drawfillbox (xx, yy, xxx, yyy, red)    %Red Box
        drawline (790, 200, 10, 200, 5) %Line
        put "You lose!"
        delay (1200)
        break
    end if     %Ending the if
    if x > 800 then %When ball goes out of screen, program says you lose
        put "You lose!"
        delay (1200)
        break
    end if
end loop
drawfillbox (xx, yy, xxx, yyy, red)     %Red Box
drawline (790, 200, 10, 200, 5)     %Line
put "Good!"
delay (900)
put ""
put "Next Level!"
delay (1200)
cls
x := 10 %Co-ordinates
y := 200 %Co-ordinates
xx := 100 %Co-ordinates
yy := 195 %Co-ordinates
xxx := 140 %Co-ordinates
yyy := 205 %Co-ordinates
loop
    drawfillbox (xx, yy, xxx, yyy, red) %Red Box
    drawline (790, 200, 10, 200, 5) %Line
    drawfilloval (x, y, 10, 10, 7) %Moving Ball
    delay (20) %Moving Ball
    drawfilloval (x, y, 10, 10, 0) %Moving Ball
    x := x + 3 %Speed
    mousewhere (t, h, button) %Mousewhere
    if x >= 100 and x <= 140 and y >= 195 and y <= 205 and button = 1 then
        exit %If ball is clicked while in the red, it will exit
    elsif button = 1 then
        drawfillbox (xx, yy, xxx, yyy, red)    %Red Box
        drawline (790, 200, 10, 200, 5) %Line
        put "You lose!"
        delay (1200)
        break
    end if     %Ending the if
    if x > 800 then %When ball goes out of screen, program says you lose
        put "You lose!"
        delay (1200)
        break
    end if
end loop
drawfillbox (xx, yy, xxx, yyy, red)     %Red Box
drawline (790, 200, 10, 200, 5)     %Line
put "Good!"
delay (900)
put ""
put "Next Level!"
delay (1200)
cls
x := 10 %Co-ordinates
y := 200 %Co-ordinates
xx := 400 %Co-ordinates
yy := 195 %Co-ordinates
xxx := 420 %Co-ordinates
yyy := 205 %Co-ordinates
for g : 1 .. 120
    drawfillbox (xx, yy, xxx, yyy, red) %Red Box
    drawline (790, 200, 10, 200, 5) %Line
    drawfilloval (x, y, 10, 10, 7) %Moving Ball
    delay (20) %Moving Ball
    drawfilloval (x, y, 10, 10, 0) %Moving Ball
    x := x + 3 %Speed
    mousewhere (t, h, button)   %Mousewhere
    if x >= 400 and x <= 420 and y >= 195 and y <= 205 and button = 1 then
        exit %If ball is clicked while in the red, it will exit
    elsif button = 1 then
        drawfillbox (xx, yy, xxx, yyy, red)    %Red Box
        drawline (790, 200, 10, 200, 5) %Line
        put "You lose!"
        delay (1200)
        break
    end if     %Ending the if
    if x > 800 then %When ball goes out of screen, program says you lose
        put "You lose!"
        delay (1200)
        break
    end if
end for
for g : 1 .. 50
    drawfillbox (xx, yy, xxx, yyy, red) %Red Box
    drawline (790, 200, 10, 200, 5) %Line
    drawfilloval (x, y, 10, 10, 7) %Moving Ball
    delay (20) %Moving Ball
    drawfilloval (x, y, 10, 10, 0) %Moving Ball
    x := x - 3 %Speed
    mousewhere (t, h, button)   %Mousewhere
    if x >= 400 and x <= 420 and y >= 195 and y <= 205 and button = 1 then
        exit %If ball is clicked while in the red, it will exit
    elsif button = 1 then
        drawfillbox (xx, yy, xxx, yyy, red)    %Red Box
        drawline (790, 200, 10, 200, 5) %Line
        put "You lose!"
        delay (1200)
        break
    end if     %Ending the if
    if x > 800 then %When ball goes out of screen, program says you lose
        put "You lose!"
        delay (1200)
        break
    end if
end for
for g : 1 .. 120
    drawfillbox (xx, yy, xxx, yyy, red) %Red Box
    drawline (790, 200, 10, 200, 5) %Line
    drawfilloval (x, y, 10, 10, 7) %Moving Ball
    delay (20) %Moving Ball
    drawfilloval (x, y, 10, 10, 0) %Moving Ball
    x := x + 3 %Speed
    mousewhere (t, h, button) %Mousewhere
    if x >= 400 and x <= 420 and y >= 195 and y <= 205 and button = 1 then
        exit %If ball is clicked while in the red, it will exit
    elsif button = 1 then
        drawfillbox (xx, yy, xxx, yyy, red)    %Red Box
        drawline (790, 200, 10, 200, 5) %Line
        put "You lose!"
        delay (1200)
        break
    end if     %Ending the if
    if x > 800 then %When ball goes out of screen, program says you lose
        put "You lose!"
        delay (1200)
        break
    end if
end for
drawfillbox (xx, yy, xxx, yyy, red)     %Red Box
drawline (790, 200, 10, 200, 5)     %Line
put "Good!"
delay (900)
put ""
put "Next Level!"
delay (1200)
cls
x := 10 %Co-ordinates
y := 200 %Co-ordinates
xx := 500 %Co-ordinates
yy := 230 %Co-ordinates
xxx := 560 %Co-ordinates
yyy := 170 %Co-ordinates
drawfillbox (xx, yy, xxx, yyy, red)    %Red Box
drawline (790, 200, 10, 200, 5)    %Line
drawfilloval (x, y, 10, 10, 7)     %Moving Ball
delay (970)
cls
loop
    drawline (790, 200, 10, 200, 5) %Line
    drawfilloval (x, y, 10, 10, 7) %Moving Ball
    delay (20) %Moving Ball
    drawfilloval (x, y, 10, 10, 0) %Moving Ball
    x := x + 2 %Speed
    mousewhere (t, h, button) %Mousewhere
    if x >= 500 and x <= 560 and y >= 170 and y <= 230 and button = 1 then
        exit %If ball is clicked while in the red, it will exit
    elsif button = 1 then
        drawfillbox (xx, yy, xxx, yyy, red)    %Red Box
        drawline (790, 200, 10, 200, 5) %Line
        put "You lose!"
        delay (1200)
        break
    end if     %Ending the if
    if x > 800 then %When ball goes out of screen, program says you lose
        put "You lose!"
        delay (1200)
        break
    end if
end loop
drawline (790, 200, 10, 200, 5)     %Line
drawfillbox (xx, yy, xxx, yyy, red)     %Red Box
put "Good!"
delay (900)
put ""
put "Next Level!"
delay (1200)
cls
x := 10 %Co-ordinates
y := 200 %Co-ordinates
xx := 520 %Co-ordinates
yy := 190 %Co-ordinates
xxx := 500 %Co-ordinates
yyy := 210 %Co-ordinates
loop
    drawfillbox (xx, yy, xxx, yyy, red) %Red Box
    drawline (790, 200, 10, 200, 5) %Line
    drawfilloval (x, y, 10, 10, 7) %Moving Ball
    delay (20) %Moving Ball
    drawfilloval (x, y, 10, 10, 0) %Moving Ball
    x := x + 7 %Speed
    mousewhere (t, h, button) %Mousewhere
    if x >= 500 and x <= 520 and y >= 190 and y <= 210 and button = 1 then
        exit %If ball is clicked while in the red, it will exit
    elsif button = 1 then
        drawfillbox (xx, yy, xxx, yyy, red)    %Red Box
        drawline (790, 200, 10, 200, 5) %Line
        put "You lose!"
        delay (1200)
        break
    end if     %Ending the if
    if x > 800 then %When ball goes out of screen, program says you lose
        put "You lose!"
        delay (1200)
        break
    end if
end loop
drawfillbox (xx, yy, xxx, yyy, red)     %Red Box
drawline (790, 200, 10, 200, 5)     %Line
put "Good!"
delay (900)
put ""
put "Next Level!"
delay (1200)
cls
x := 10 %Co-ordinates
y := 200 %Co-ordinates
xx := 520 %Co-ordinates
yy := 190 %Co-ordinates
xxx := 500 %Co-ordinates
yyy := 210 %Co-ordinates
for g : 1 .. 50
    drawfillbox (xx, yy, xxx, yyy, red) %Red Box
    drawline (790, 200, 10, 200, 5) %Line
    drawfilloval (x, y, 10, 10, 7) %Moving Ball
    delay (20) %Moving Ball
    drawfilloval (x, y, 10, 10, 0) %Moving Ball
    x := x + 1 %Speed
    mousewhere (t, h, button)       %Mousewhere
    if x >= 500 and x <= 520 and y >= 190 and y <= 210 and button = 1 then
        exit %If ball is clicked while in the red, it will exit
    elsif button = 1 then
        drawfillbox (xx, yy, xxx, yyy, red)    %Red Box
        drawline (790, 200, 10, 200, 5) %Line
        put "You lose!"
        delay (1200)
        break
    end if     %Ending the if
    if x > 800 then %When ball goes out of screen, program says you lose
        put "You lose!"
        delay (1200)
        break
    end if
end for
for g : 1 .. 30
    drawfillbox (xx, yy, xxx, yyy, red) %Red Box
    drawline (790, 200, 10, 200, 5) %Line
    drawfilloval (x, y, 10, 10, 7) %Moving Ball
    delay (20) %Moving Ball
    drawfilloval (x, y, 10, 10, 0) %Moving Ball
    x := x + 4 %Speed
    mousewhere (t, h, button)       %Mousewhere
    if x >= 500 and x <= 520 and y >= 190 and y <= 210 and button = 1 then
        exit %If ball is clicked while in the red, it will exit
    elsif button = 1 then
        drawfillbox (xx, yy, xxx, yyy, red)    %Red Box
        drawline (790, 200, 10, 200, 5) %Line
        put "You lose!"
        delay (1200)
        break
    end if     %Ending the if
    if x > 800 then %When ball goes out of screen, program says you lose
        put "You lose!"
        delay (1200)
        break
    end if
end for
for g : 1 .. 40
    drawfillbox (xx, yy, xxx, yyy, red) %Red Box
    drawline (790, 200, 10, 200, 5) %Line
    drawfilloval (x, y, 10, 10, 7) %Moving Ball
    delay (20) %Moving Ball
    drawfilloval (x, y, 10, 10, 0) %Moving Ball
    x := x + 7 %Speed
    mousewhere (t, h, button)       %Mousewhere
    if x >= 500 and x <= 520 and y >= 190 and y <= 210 and button = 1 then
        exit %If ball is clicked while in the red, it will exit
    elsif button = 1 then
        drawfillbox (xx, yy, xxx, yyy, red)    %Red Box
        drawline (790, 200, 10, 200, 5) %Line
        put "You lose!"
        delay (1200)
        break
    end if     %Ending the if
    if x > 800 then %When ball goes out of screen, program says you lose
        put "You lose!"
        delay (1200)
        break
    end if
end for
for g : 1 .. 40
    drawfillbox (xx, yy, xxx, yyy, red) %Red Box
    drawline (790, 200, 10, 200, 5) %Line
    drawfilloval (x, y, 10, 10, 7) %Moving Ball
    delay (20) %Moving Ball
    drawfilloval (x, y, 10, 10, 0) %Moving Ball
    x := x - 7 %Speed
    mousewhere (t, h, button)       %Mousewhere
    if x >= 500 and x <= 520 and y >= 190 and y <= 210 and button = 1 then
        exit %If ball is clicked while in the red, it will exit
    elsif button = 1 then
        drawfillbox (xx, yy, xxx, yyy, red)    %Red Box
        drawline (790, 200, 10, 200, 5) %Line
        put "You lose!"
        delay (1200)
        break
    end if     %Ending the if
    if x > 800 then %When ball goes out of screen, program says you lose
        put "You lose!"
        delay (1200)
        break
    end if
end for
for g : 1 .. 20
    drawfillbox (xx, yy, xxx, yyy, red) %Red Box
    drawline (790, 200, 10, 200, 5) %Line
    drawfilloval (x, y, 10, 10, 7) %Moving Ball
    delay (20) %Moving Ball
    drawfilloval (x, y, 10, 10, 0) %Moving Ball
    x := x - 3 %Speed
    mousewhere (t, h, button)       %Mousewhere
    if x >= 500 and x <= 520 and y >= 190 and y <= 210 and button = 1 then
        exit %If ball is clicked while in the red, it will exit
    elsif button = 1 then
        drawfillbox (xx, yy, xxx, yyy, red)    %Red Box
        drawline (790, 200, 10, 200, 5) %Line
        put "You lose!"
        delay (1200)
        break
    end if     %Ending the if
    if x > 800 then %When ball goes out of screen, program says you lose
        put "You lose!"
        delay (1200)
        break
    end if
end for
for g : 1 .. 320
    drawfillbox (xx, yy, xxx, yyy, red) %Red Box
    drawline (790, 200, 10, 200, 5) %Line
    drawfilloval (x, y, 10, 10, 7) %Moving Ball
    delay (20) %Moving Ball
    drawfilloval (x, y, 10, 10, 0) %Moving Ball
    x := x + 3 %Speed
    mousewhere (t, h, button)       %Mousewhere
    if x >= 500 and x <= 520 and y >= 190 and y <= 210 and button = 1 then
        exit %If ball is clicked while in the red, it will exit
    elsif button = 1 then
        drawfillbox (xx, yy, xxx, yyy, red)    %Red Box
        drawline (790, 200, 10, 200, 5) %Line
        put "You lose!"
        delay (1200)
        break
    end if     %Ending the if
    if x > 800 then %When ball goes out of screen, program says you lose
        put "You lose!"
        delay (1200)
        break
    end if
end for
loop
    mousewhere (t, h, button)   %Mousewhere
    if x >= 500 and x <= 520 and y >= 190 and y <= 210 and button = 1 then
        exit %If ball is clicked while in the red, it will exit
    elsif button = 1 then
        drawfillbox (xx, yy, xxx, yyy, red)    %Red Box
        drawline (790, 200, 10, 200, 5) %Line
        put "You lose!"
        delay (1200)
        break
    end if     %Ending the if
    if x > 800 then %When ball goes out of screen, program says you lose
        put "You lose!"
        delay (1200)
        break
    end if
end loop
drawfillbox (xx, yy, xxx, yyy, red)     %Red Box
drawline (790, 200, 10, 200, 5)     %Line
put "Good!"
delay (900)
put ""
put "Next Level!"
delay (1200)
cls
var xxxx, yyyy, xxxxx, yyyyy : int %Variables
x := 10 %Co-ordinates
y := 200 %Co-ordinates
xx := 520 %Co-ordinates
yy := 190 %Co-ordinates
xxx := 500 %Co-ordinates
yyy := 210 %Co-ordinates
xxxx := 140
yyyy := 190
xxxxx := 122
yyyyy := 210
loop
    drawfillbox (xxxx, yyyy, xxxxx, yyyyy, red) %Other Box
    drawfillbox (xx, yy, xxx, yyy, red) %Red Box
    drawline (790, 200, 10, 200, 5) %Line
    drawfilloval (x, y, 10, 10, 7) %Moving Ball
    delay (20) %Moving Ball
    drawfilloval (x, y, 10, 10, 0) %Moving Ball
    x := x + 2 %Speed
    mousewhere (t, h, button) %Mousewhere
    if x >= 122 and x <= 140 and y >= 190 and y <= 210 and button = 1 then
        exit
    elsif button = 1 then
        drawfillbox (xx, yy, xxx, yyy, red) %Red Box
        drawline (790, 200, 10, 200, 5) %Line
        put "You lose, you missed the first one!"
        delay (3200)
        break
    end if  %Ending the if
    if x > 800 then %When ball goes out of screen, program says you lose
        put "You lose!"
        delay (1200)
        break
    end if
end loop
loop
    drawfillbox (xxxx, yyyy, xxxxx, yyyyy, red) %Other Box
    drawfillbox (xx, yy, xxx, yyy, red) %Red Box
    drawline (790, 200, 10, 200, 5) %Line
    drawfilloval (x, y, 10, 10, 7) %Moving Ball
    delay (20) %Moving Ball
    drawfilloval (x, y, 10, 10, 0) %Moving Ball
    x := x + 2 %Speed
    mousewhere (t, h, button) %Mousewhere
    if x >= 500 and x <= 520 and y >= 190 and y <= 210 and button = 1 then
        exit %If ball is clicked while in the red, it will exit
    elsif button = 1 then
        drawfillbox (xx, yy, xxx, yyy, red) %Red Box
        drawline (790, 200, 10, 200, 5) %Line
    end if %Ending the if
    if x > 800 then %When ball goes out of screen, program says you lose
        put "You lose!"
        delay (1200)
        break
    end if
end loop
drawfillbox (xx, yy, xxx, yyy, red)     %Red Box
drawline (790, 200, 10, 200, 5)     %Line
put "Good!"
delay (900)
put ""
put "Next Level!"
delay (1200)
cls
%circa_appleyard707@hotmail.com
Sponsor
Sponsor
Sponsor
sponsor
upthescale




PostPosted: Wed Mar 15, 2006 12:22 pm   Post subject: hey

here it is
[Gandalf]




PostPosted: Wed Mar 15, 2006 5:02 pm   Post subject: (No subject)

About your commenting... You don't need comments for things which the code expresses already. Things like "% variables" don't tell us anything new, and are therefore pointless. Really, all of your comments are useless, because the code is self explanatory.
jamonathin




PostPosted: Wed Mar 15, 2006 6:22 pm   Post subject: (No subject)

Also, dont post everytime you have something to add to a topic. You posted 4 times in 10 muinutes, where none of them were really necessary, except for maybe the last one. This is called spamming, and it will get you in trouble in the future. Wink
MysticVegeta




PostPosted: Wed Mar 15, 2006 8:12 pm   Post subject: (No subject)

Your same code (without the rules) in 58 lines, better, more effiecient and more random and simple # of change. Just a little Math and arrays/efficiency can go a long way Wink
code:
setscreen ("offscreenonly")
var font := Font.New ("chiller:60:bold")
var messages : array 1 .. 3 of string := init ("The", "Square", "Game")
var dx : array 1 .. 3 of int := init (600, 550, 100)
var dy : array 1 .. 3 of int := init (400, 400, 400)
var x, y, b, randX, randSize : int
var level := 1
var useX := maxx div 2
var useY := maxy div 2
var mx := 0

put "This game is called..."
delay (1000)

for s : 1 .. 3
    for xx : 1 .. 120
        Font.Draw (messages (s), dx (s), dy (s), font, brightblue)
        delay (10)
        cls
        Font.Draw (messages (s), dx (s), dy (s), font, brightblue)
        dx (s) -= 3
        dy (s) -= 3
        View.Update
    end for
end for

loop
    randX := Rand.Int (useX - (level * 3), maxx - 100)
    randSize := 22 - level * 3
    mx := 0
    loop
        mousewhere (x, y, b)
        mx += 1
        cls
        drawfilloval (mx, useY, 5, 5, red)
        locate (1, 1)
        put "Level: ", level
        drawfillbox (randX, useY - (randSize div 2), randX + randSize, useY + (randSize div 2), blue)
        drawline (0, useY, useX * 2, useY, 255)
        mousewhere (x, y, b)
        if x > randX - 7 and x < randX + randSize + 7 and mx > randX - 7 and mx < randX + randSize + 7 and b = 1 then
            locate (2, 1)
            put "You Win."
            delay (100)
            level += 1
            exit
        elsif b = 1 then
            locate (2, 1)
            put "You Lose."
            delay (100)
            level := 1
            exit
        end if
        delay (randSize div 5) %Increase the 5 to make it even faster
        View.Update
    end loop
    exit when level = 6 %Increase this to increase the # of levels
end loop
put "YOU PWNED ALL LEVELS, YOU LUCKY !@#$%"
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  [ 12 Posts ]
Jump to:   


Style:  
Search: