Catch The Sparkles!
Author |
Message |
Guest
|
Posted: Sun Jul 30, 2006 8:30 pm Post subject: Catch The Sparkles! |
|
|
Here is a quick game I made, called catch the sparkles! It has really no score or anything, but it's kinda hard to "catch" them all. Use LEFT and RIGHT to move around, you'll see what I mean lol.
code: |
Mouse.ButtonChoose ("multibutton")
View.Set ("title:Ball Stretch,graphics:650;600,offscreenonly,nobuttonbar,nocursor")
var xaxis, yaxis, width, height, wgrow, hgrow, mousex, mousey, button : int
var left, middle, right, back, col, cnt : int
var debugger : boolean := false
var keys : array char of boolean
xaxis := 100
yaxis := 100
width := 10
height := 50
wgrow := 1
left := 1
cnt := 1
middle := 10
right := 100
hgrow := 3
back := black
col := white
drawfillbox (0, 0, maxx, maxy, back)
loop
Mouse.Where (mousex, mousey, button)
Input.KeyDown (keys)
locate (1, 1)
colourback (back)
color (white)
if debugger = true then
put "X: ", xaxis, " Y: ", yaxis, " Mouse X: ", mousex, " Mouse Y: ", mousey, " Button: ", button, " Height: ", height, " Width: ", width, " Col: ", col
else
put ""
end if
drawoval (xaxis, yaxis, width, height, col)
View.Update
drawfilloval (xaxis, yaxis, width, height, back)
height += hgrow
width += wgrow
col += 1
delay (3)
if keys ('a') or keys (KEY_LEFT_ARROW) then
xaxis -= 1
elsif keys ('d') or keys (KEY_RIGHT_ARROW) then
xaxis += 1
end if
if keys ('w') or keys (KEY_UP_ARROW) then
yaxis += 1
elsif keys ('s') or keys (KEY_DOWN_ARROW) then
yaxis -= 1
end if
if keys (KEY_ENTER) then
Input.Flush
Input.Pause
end if
if keys (KEY_F10) then
delay (100)
if debugger = false then
debugger := true
else
debugger := false
end if
end if
if height >= 80 or height <= 0 then
hgrow := -hgrow
end if
if width >= 80 or width <= 0 then
wgrow := -wgrow
end if
if button = left then
drawdot (mousex, mousey, col)
elsif button = middle then
drawoval (mousex, mousey, width, height, col)
View.Update
drawfilloval (mousex, mousey, width, height, back)
elsif button = right then
drawoval (mousex, mousey, width, height, col)
end if
if button >= 1 then
cnt += 1
View.Set ("title:Ball Stretch " + intstr (cnt))
end if
if col = 255 then
col := 1
end if
end loop
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
NikG
|
Posted: Sun Jul 30, 2006 8:52 pm Post subject: (No subject) |
|
|
There's an error when I run your game... something with the cnt variable (which I'm guessing is not declared anywhere). |
|
|
|
|
|
Guest
|
Posted: Sun Jul 30, 2006 8:56 pm Post subject: (No subject) |
|
|
Fixed it, was in the middle of editing and posting. |
|
|
|
|
|
Clayton
|
Posted: Sun Jul 30, 2006 9:07 pm Post subject: (No subject) |
|
|
ya he didnt declare "cnt" (what does that stand for? it just looks/sounds wrong...) just declare it at the top of the program as an int = 0 , anyways, on to the program.
i notice in this program (and some others of yours as well) that you are using commands like drawfillbox (), drawdot (), etc etc, as opposed to Draw.FillBox and Draw.Dot respectively, why is this, i recall you were saying before that modules were confusing you, but if you were to use commands such as Draw.Dot instead of drawdot, you might find yourself feeling more comfortable with modules later.
i notice that you are doing something very strange in here too, why are you drawing a big black box on the background outside of your loop, then using colourback (Text.ColourBack) to change the background color to black anyways within the loop?
small things but stuff to think about |
|
|
|
|
|
Guest
|
Posted: Mon Jul 31, 2006 8:33 pm Post subject: (No subject) |
|
|
Ok first off, "cnt" is known to most programmers as a "counter". Not a female body part which you said "sounded wrong"... So it's just a simple "variable" that count's up to see how many times a specific action was called.
I started using drawfillbox etc. other than Draw.FillBox because they both have the same output, just trying something new and lazier than hitting "SHIFT" and "."...
I don't feel like re-drawing the box over and over and wish to use it as a bottom layer to draw things on without erasing the picture, just seems more fresh. |
|
|
|
|
|
NikG
|
Posted: Mon Jul 31, 2006 10:18 pm Post subject: (No subject) |
|
|
vahnx wrote: "cnt" is known to most programmers as a "counter" So why not just use "counter"? Also, are you calling yourself a programmer? Because if you are:
vahnx wrote: I started using drawfillbox etc. other than Draw.FillBox because they both have the same output, just trying something new and lazier than hitting "SHIFT" and "." A programmer would realize that there is a real advantage to using the Draw.whatever methods as opposed to the drawwhatever procedures (such as learning to use modules as SF82 mentioned and just better programming in general).
Also, real programmers are not lazy (at least not in the same way as you seem to be). If there's a better way to do something, use it!
vahnx wrote: I don't feel like re-drawing the box over and over and wish to use it as a bottom layer to draw things on without erasing the picture, just seems more fresh. Refer to the laziness comment above. |
|
|
|
|
|
Guest
|
Posted: Tue Aug 01, 2006 6:29 am Post subject: (No subject) |
|
|
drawfillbox = Draw.FillBox (same result). Like putting Draw.FillBox vs drawfillbox is gonna teach me anything... There is no real advantage unless you make your own classes/procedures/methods/modules, which I am not doing in the above code. If I decide to make this a full time project, then I will re-write it.
Drawing a box only once has it's advantages, as it is not constantly running that piece of code in a loop so it doesn't erase everything underneath. It makes it a "perminant" bottom layer outside of the loop. Imagine if it was in the loop, I would have to draw the box, draw everything else, draw the box, redraw everything else, etc... It's nice having it draw once and have everything else floating above it (like it matters in my code).
I hope you all understand my point of view in trying different methods to achieve the same results, that's what a real programmer does.
Later on when I feel like it, I will change the delay so it doesn't massivly slow down when you "middle click".
PS What's with you guys and not knowing cnt meaning counter? Maybe it's just a thing our teacher taught us. |
|
|
|
|
|
Cervantes
|
Posted: Tue Aug 01, 2006 7:33 am Post subject: (No subject) |
|
|
vahnx wrote: drawfillbox = Draw.FillBox (same result). Like putting Draw.FillBox vs drawfillbox is gonna teach me anything... There is no real advantage unless you make your own classes/procedures/methods/modules, which I am not doing in the above code. If I decide to make this a full time project, then I will re-write it.
You should use the Draw.FillBox style because the drawfillbox style should never have been added to Turing.
Let me ask you something. Do you know, off the top of your head, where the code (or just the function definition) for "drawfillbox" resides? How would you find it?
vahnx, you need to learn to take constructive criticism. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Clayton
|
Posted: Tue Aug 01, 2006 8:05 am Post subject: (No subject) |
|
|
vahnx wrote:
Drawing a box only once has it's advantages, as it is not constantly running that piece of code in a loop so it doesn't erase everything underneath. It makes it a "perminant" bottom layer outside of the loop. Imagine if it was in the loop, I would have to draw the box, draw everything else, draw the box, redraw everything else, etc... It's nice having it draw once and have everything else floating above it (like it matters in my code).
not quite
that box is erased as soon as you use your first cls (preferably Draw.Cls), from that point onward, the only reason your background stays black is because you are using colorback (black), which sets the background color black, that box that you are drawing is essentially useless... |
|
|
|
|
|
Guest
|
Posted: Tue Aug 01, 2006 8:20 pm Post subject: (No subject) |
|
|
Quote: vahnx, you need to learn to take constructive criticism.
Hah I love messing with all you forum boys =p Me and my friend get a kick out of how serious you guys are. |
|
|
|
|
|
Cervantes
|
Posted: Tue Aug 01, 2006 9:31 pm Post subject: (No subject) |
|
|
You sit at the computer with your friend reading forums?
Ha, we get it kick out of you too. |
|
|
|
|
|
Mazer
|
Posted: Wed Aug 02, 2006 8:37 am Post subject: (No subject) |
|
|
Man I love that picture.
There's a difference between being serious about everything (trust me, I've been there) and being serious about learning something properly (yet still taking the time to have fun). |
|
|
|
|
|
TokenHerbz
|
Posted: Wed Aug 02, 2006 11:16 pm Post subject: (No subject) |
|
|
And where are your comments...
i made a mistake ill never do again, that is i was righting an RPG which i knew everything to it, but a few months later i take a look, and i didnt know what did what etc:
even the smallest programms deserve comments get it the habbit of it, its good for yeah |
|
|
|
|
|
|
|