 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Iximon
Joined: 08 Sep 2005 Posts: 5
|
Posted: Thu Sep 08, 2005 6:33 am Post subject: help a noob |
|
|
i have just started to play whit lua and have done the hello world. but i cant use it on my psp because i have 1.52 :( so i use the win emu. i have also made the animation tutorial, but i have a problem whit my own program i have started with. ist very simpel. but i cant compile it. here is the code:
| Code: | background = Image.load("background.png")
player = Image.load("player.png")
while true do
screen:blit(0, 0, background, 0, 0, background:width(), background:height(), false)
x = 200
y = 135
screen:blit(x, y, player)
end
pad = Controls.read()
if pad:right() then
x = x + 1
end
if pad:left() then
x = x - 1
end
if pad:up() then
y = y + 1
end
if pad:down() then
y = y - 1
end
screen:waitVblankStart()
screen:flip()
end |
when i try to compile i get a error: <eof> expected near 'end' and i have no ide how to fix it. can u please tell me what i have done wrong. |
|
| Back to top |
|
 |
zhaD
Joined: 07 Sep 2005 Posts: 5 Location: Québec/Canada
|
Posted: Thu Sep 08, 2005 6:45 am Post subject: |
|
|
<eof> expected near 'end'
guess it means it expected the end of the script file instead of 'end' (on last line).
looking at your code Id say you should remove the 'end' under :
x = 200
y = 135
screen:blit(x, y, player)
end <---
as it doesnt seem to be related to any if or while |
|
| Back to top |
|
 |
ksilvert
Joined: 06 Sep 2005 Posts: 5
|
Posted: Fri Sep 09, 2005 2:30 am Post subject: |
|
|
If you're trying to have the 'player' move around based on the D pad selection, you'll need to move these two lines above the beginning of the while loop or your image won't move.
x = 200
y = 135 |
|
| Back to top |
|
 |
LuMo
Joined: 21 Aug 2005 Posts: 410 Location: Austria
|
Posted: Fri Sep 09, 2005 2:36 am Post subject: |
|
|
| Code: | | while not Controls.read():start() do |
would enable to leave the program again (eg for use in lowser) |
|
| Back to top |
|
 |
F34R
Joined: 28 Jul 2005 Posts: 29
|
Posted: Sat Sep 10, 2005 1:17 pm Post subject: |
|
|
Here's a little code that I wrote to control an object moving with the dpad. It also tells you what direction you are pressing, along with the buttons (circle, square, cross, triangle) that you are pressing.
| Code: |
-- Activate USB Mode
System.usbDiskModeActivate()
-- Get colors for text
white = Color.new(255, 255, 255)
red = Color.new(255, 0, 0)
-- Load images
square = Image.load("square.png") -- This is the object we'll be controlling
-- Set starting X/Y positions
x = 200
y = 100
while true do
pad = Controls.read()
-- This all should be relatively easy to follow from here
if pad:up() then
screen:clear()
screen:print(200,1, "You Pressed Up", white)
y = y - 5
if y < -4 then
y = -4
end
end
if pad:down() then
screen:clear()
screen:print(200,1, "You Pressed Down", white)
y = y + 5
if y > 230 then
y = 230
end
end
if pad:left() then
screen:clear()
screen:print(200,1, "You Pressed Left", white)
x = x - 5
if x < -4 then
x = -4
end
end
if pad:right() then
screen:clear()
screen:print(200,1, "You Pressed Right", white)
x = x + 5
if x > 440 then
x = 440
end
end
if pad:cross() then
screen:clear()
screen:print(200,1, "You Pressed [CROSS]", white)
end
if pad:triangle() then
screen:clear()
screen:print(200,1, "You Pressed [TRIANGLE]", white)
end
if pad:square() then
screen:clear()
screen:print(200,1, "You Pressed [SQUARE]", white)
end
if pad:circle() then
screen:clear()
screen:print(200,1, "You Pressed [CIRCLE]", white)
end
if pad:start() then
break
end
-- Draw my little square
screen:blit(x, y, square) -- Draws to offscreen
screen.flip() -- flips offscreen to onscreen
end
|
|
|
| Back to top |
|
 |
Iximon
Joined: 08 Sep 2005 Posts: 5
|
Posted: Wed Sep 14, 2005 5:23 pm Post subject: |
|
|
i have made some progres, but i have a problem. my images dont turn invisible. the color i dont want in my game, show up. i have lookt at other games images and i have taken the same color. 255, 0, 255 but it wont disepere. i also wondering hor to make a array. is there any tutorials for the array making. sorry for my english. :( here is the code:
| Code: | background = Image.load("images/background.png")
-- ladda bakgrundsbild
player = Image.load("images/marioright2.png")
-- ladda spelarbild
board = Image.load("images/board.png")
-- ladda animation
moveright1 = Image.load("images/marioright1.png")
moveright2 = Image.load("images/marioright2.png")
moveright3 = Image.load("images/marioright3.png")
moveleft1 = Image.load("images/marioleft1.png")
moveleft2 = Image.load("images/marioleft2.png")
moveleft3 = Image.load("images/marioleft3.png")
player = moveright1
-- ladda board
playerx = 100
playery = 100
move = 0
-- var x och y kordinaterna ska vara ifrån start
speed = 1
-- bestämmer hastigheten på player
green = Color.new(0, 255, 0)
-- delkarera green till färgen grön
bPressOnce1 = 0
bPressOnce2 = 0
while true do
pad = Controls.read() -- kontrollerna
if pad:left() then
if bPressOnce1 == 0 then
move= 0
end
bPressOnce1 = true;
playerx = playerx - speed
move = move + 1
if move == 1 then
player = moveleft1
end
if move == 8 then
player = moveleft2
end
if move == 15 then
player = moveleft3
move = 0
end
end
if pad:left() == 0 then
bPressOnce1 = false
end
if pad:right() then
if bPressOnce2 == 0 then
move = 0
end
bPressOnce2 = true;
playerx = playerx + speed
move = move + 1
if move == 1 then
player = moveright1
end
if move == 8 then
player = moveright2
end
if move == 15 then
player = moveright3
move = 0
end
end
if pad:right() == 0 then
bPressOnce2 = false
end
if pad:up() then
playery = playery - speed
end
if pad:down() then
playery = playery + speed
end
if pad:cross() then
break
end
if pad:triangle() then
speed = speed + 0.5
end
if pad:square() then
speed = speed - 0.5
end
if playerx > 448 then -- blockera så att den inte kan åka utanför skärmen :)
playerx = 448
end
if playerx < 0 then
playerx = 0
end
if playery > 240 then
playery = 240
end
if playery < 0 then
playery = 0
end --här sluta blockeringen
screen:blit(0, 0, background, 0, 0, background:width(), background:height(), false)
-- blitta bakgrunden till skärmen
screen:blit(playerx, playery, player)
--blitta player till skärmen
screen:blit(0, 0, board)
screen:print(4, 4, "Speed:", green)
screen:print(50, 4, speed, green)
screen:print(4, 14, "X pos:", green)
screen:print(50, 14, playerx, green)
screen:print(4, 24, "Y pos:", green)
screen:print(50, 24, playery, green)
-- skriver ut speed, Y och X värden i vänstra hörnet på skärmen
screen.waitVblankStart()
screen.flip()
-- vänd skärmen så att man ser allt.
end |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|