I' am up to make my first game.
This is gonna be a simple catch' em game´, with a object
you can move in the bottom of the "gaming field". And randomized falling squares.
Just to test some functions I' ve binded CROSS to increase the score and
SQUARE to get the randomized square to move down.
Now here comes my problem, when the square reach the bottom the SCORE increases, but I want the score to increase when the square hit the "cursor". So you can catch' em up.
And the second and the biggest problem, I need to do a function wich makes squares, and randomize them, then they auto fall down. One by one you catch' em. If they drop into the ground GAME IS OVER!
Can't save the highscore either..
Yes, I am a newbie but someone please help me, that would be really gracefully :)
Here is the script:
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) -- To random the "points" in the falling. --
r1 = 0
m0 = math.random(261)
-- 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 pad:square() then
r1 = r1 + 2
end
if r1 == 262 then
score = score + 1
elseif r1 > 261 then
r1 = 0
end
-- Highscore and Score function --
if pad:cross() then
score = score + 1
end
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 ! --
-- Objects --
screen:fillRect(r0, r1, 10, 10, white)
screen:fillRect(x0, y0, 45, 5, 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 --
screen.flip()
screen:waitVblankStart()
if pad:start() then
break
end
end