Wiki
Clone wikiCore / kidfunc
After we colored bubbles our code was this:
-- Use this function to perform your initial setup
function setup()
spx = 100 -- Spritey x
spy = 100 -- Spritey y
print("Hello World!")
print("Look at me go!")
parameter.watch("spx")
parameter.watch("spy")
end
-- This function gets called once every frame
function draw()
-- This sets the background color to black
background(0, 0, 0)
-- Do your drawing here
sprite("SpaceCute:Background",374,374)
spx = spx + Gravity.x
spy = spy + Gravity.y
tint(0, 255, 0, 255)
sprite("Planet Cute:Character Boy",spx,spy,101/2,171/2)
fill(0,0,255,255)
noFill()
strokeWidth(10)
ellipse(200,100,100,100)
--rect(200,100,100,100)
end
function touched(touch)
spx = touch.x
spy = touch.y
end
Our code has gotten quite messy. We are going to learn how to organize it so we can find things but keep it working.
After the very last end add this:
function watchstuff()
end
Now play. If every went well you should nothing change with Spritey. Remember, this is about organization so we can play more complex games later.
Now move these lines...
parameter.watch("spx")
parameter.watch("spy")
...into your function like this:
function watchstuff()
parameter.watch("spx")
parameter.watch("spy")
end
Now those numbers that show Spritey's position are missing. Let's bring them back.
Go back to where we took those watch lines out and add this:
print("Look at me go!")
watchstuff()
end
If everthing went well you should see Spritey's position again.
Now, time to send Spritey to class
Updated