Computer Science Canada Game in the works |
Author: | upthescale [ 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 |
Author: | TokenHerbz [ Wed Mar 15, 2006 12:05 am ] |
Post 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... |
Author: | jamonathin [ Wed Mar 15, 2006 12:54 am ] | ||||||||||
Post subject: | |||||||||||
First things first, please use code tags.
Nextly, many things to touch upon; and I'll probabily miss a few. Starting at the very top. What is
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
Something to signify it belongs to the ball, and the xx and xxx can be changed to
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:
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 ![]() |
Author: | upthescale [ Wed Mar 15, 2006 1:18 am ] |
Post 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 |
Author: | Imm0rtal [ Wed Mar 15, 2006 11:34 am ] | ||
Post subject: | |||
That was very interesting. You should use variable names you can remember. Also use comments when showing source code.. example
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 ![]() |
Author: | upthescale [ Wed Mar 15, 2006 12:12 pm ] |
Post subject: | |
i did use comments |
Author: | upthescale [ Wed Mar 15, 2006 12:19 pm ] | ||
Post subject: | |||
|
Author: | upthescale [ Wed Mar 15, 2006 12:20 pm ] | ||
Post subject: | |||
|
Author: | upthescale [ Wed Mar 15, 2006 12:22 pm ] |
Post subject: | hey |
here it is |
Author: | [Gandalf] [ Wed Mar 15, 2006 5:02 pm ] |
Post 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. |
Author: | jamonathin [ Wed Mar 15, 2006 6:22 pm ] |
Post 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. ![]() |
Author: | MysticVegeta [ Wed Mar 15, 2006 8:12 pm ] | ||
Post 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 ![]()
|