This is ALMOST working, BUT SOMETHING does that if you take a point on the right side of the cursor you get 2 points :S, and on the left side 1 point. If you just stand still after catched point, you just have one after one free when they hit the ground. PLEASE ANYONE help me.. would be VERY gracefully.
Code: Select all
System.usbDiskModeActivate()
white = Color.new(255, 255, 255)
black = Color.new(0, 0, 0)
red = Color.new(255, 0, 0)
blue = Color.new(0, 0, 255)
green = Color.new(0, 255, 0)
yellow = Color.new(0, 255, 255)
tech = Image.createEmpty(480, 272)
tech:clear(black )
highscore = 5
score = 0
line = screen:drawLine(480, 0, 480, 272, white)
x0 = 0
y0 = 262
x1 = 0
y1 = 0
r0 = math.random(480)
r1 = 0
c = 45
c1 = 5
-- But how to get them to fall, and if get it 2 sec between each ? --
-- CREATE points, HOW ? --
-- END --
while true do
pad = Controls.read()
dx = pad:analogX()
if math.abs(dx) > 32 then
x0 = x0 + dx / 20
end
if ((r1 > x0 and r0 < x0+45) or (r0+10 > x0 and r0+10 < x0+45)) and ((r1 > y0 and r1 < y0+5) or (r1+5 > y0 and r1+5 < y0+5) or (r1+10 > y0 and r1+10 < y0+5)) then
score = score + 1
end
-- Highscore and Score function --
if score > highscore then
highscore = highscore + 1
end
-- End of Highscore and Score function --
screen:blit(0, 0, tech, 0, 0, tech:width(), tech:height(), false)
-- Gaming Space --
screen:drawLine(480, 0, 480, 272, white)
screen:drawLine(480, 272, 0, 480, white)
screen:drawLine(0, 0, 480, 0, white)
screen:drawLine(0, 0, 0, 272, white)
-- End of gaming space --
screen:print(10, 10, "Raining points, randomized..", white)
screen:print(150, 130, "RikaRdo's gaming project", white)
screen:print(150, 140, "Highscore," , white)
screen:print(150, 150, "Score," , white)
-- Highscore and Score function, printed --
screen:print(230, 140, highscore, white)
screen:print(200, 150, score, white)
-- End of Highscore and Score function, printed --
-- GET the points falling ? --
-- AND if they collaps with the cursor then get a point else IF
-- hitting the bottom, GAME OVER ! --
-- Makes a object random fallin --
screen:fillRect(x0, y0, c, c1, white)
-- End of objects --
-- If the cursor goes outside the "gaming space" then let it be in there :) --
if x0 > 480 then
x0 = -46
end
if x0 < -46 then
x0 = 480
end
-- Almost the end end --
x = math.sin(5 * 2 / 360 * r1) * r0 + r1
screen:fillRect(r0, r1, 10, 10, white)
screen:print(10, 20, "r0", white)
screen:print(10, 30, "r1", white)
screen:print(30, 20, r0, white)
screen:print(30, 30, r1, white)
r1 = r1 + 2
if r1 > 256 then
r1 = 0
elseif r1 >= 256 then
r0 = math.random(480)
end
screen.flip()
screen:waitVblankStart()
if pad:start() then
break
end
end