Lua Programming Help Thread
This is a discussion on Lua Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Zitat von Altair Ok im assuming you understand SG57's explanation of why it moves to the right and then stops ...
-
07-13-2006, 06:34 PM #2791Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
lol, ive been damned many times before
Zitat von Altair
--------------------------------------------------------------------------------------
-
07-13-2006, 06:36 PM #2792
yeah i understand that i have it in a loop and a bool is very simple so thanks for your help Grimfate126, SG57, Access_Denied and Altair all of your help is greatly appreciated!
-
07-13-2006, 06:41 PM #2793Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
no prob. im bored anyway so ask if u have any more!
Zitat von pspsalv2
--------------------------------------------------------------------------------------
-
07-13-2006, 06:43 PM #2794I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
I see now! I misread the code. At first I thought that you were doing this so that if you press left or right it moves left or right. But now I see you just want the image to move back and forth across the screen. I had problems with this before. What I did was make it so that if the images collided with a side, it would start moving. Something like:
This would make it so as soon as the loop start it start moving right. But when it hit the 450 mark it starts moving left. Then when it hits 0 it moves right again. It will keep moving until you put in a line that stops it.Code:function Bounce() if image.x == 450 then image.x = image.x - 2 end if image.x == 0 then image.x = image.x + 2 end while true do screen:blit(image you want to blit) if image.x >0 and image.x < 450 then image.x = image.x + 2 end if image.x == 450 then Bounce() end screen.waitVblankStart() screen.flip() end
I think I'm on the right track, but if I'm not, disregard everything I say. :)
EDIT: I spent so much time typing the code I didn't realize that someone already answered your question. Oh well.
-
07-14-2006, 07:33 AM #2795QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
hey here is the very basiz starting code for the startmenu of my game:
the main thing is when i run it in lua player for windows all i see is a blank screen. Can you see any reason for thisCode:white = Color.new(255,255,255) black = Color.new(0,0,0) orange = Color.new(255,102,0) menu = Image.load("startmenu.png") screenwidth = 480 screenheight = 272 while true do screen:clear() screen:blit( 0, 0, menu, false) screen:print(170,70,"Start",white) screen.waitVblankStart() screen.flip() endGeändert von mark.sparky (07-14-2006 um 07:39 AM Uhr)
-
07-14-2006, 07:46 AM #2796Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
when u bilt the menu, dont put "false". try this:
Zitat von mark.sparky
Code:white = Color.new(255,255,255) black = Color.new(0,0,0) orange = Color.new(255,102,0) menu = Image.load("startmenu.png") screenwidth = 480 screenheight = 272 while true do screen:clear() screen:blit( 0, 0, menu) screen:print(170,70,"Start",white) screen.waitVblankStart() screen.flip() end--------------------------------------------------------------------------------------
-
07-14-2006, 07:51 AM #2797QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
no it didnt work it is still blank and the cmd now says:
Luaplayer's Mikmod has a critical error:
_mm_critical 1
_mm_ errno 15
None of the supported the sound-devices were detected
-
07-14-2006, 07:54 AM #2798Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
post your menu pic. what fromat is it?
Zitat von mark.sparky
--------------------------------------------------------------------------------------
-
07-14-2006, 07:59 AM #2799QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
here is my menu (please dont use it anyone).
. it is png
-
07-14-2006, 08:07 AM #2800Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
hmm, try it on your psp. it doesnt work for me either.
Zitat von mark.sparky
--------------------------------------------------------------------------------------
-
07-14-2006, 08:27 AM #2801QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
k did you mean it doesnt work on luaplayer windows
-
07-14-2006, 08:39 AM #2802Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
i guess. does it work on ur psp tho?
Zitat von mark.sparky
--------------------------------------------------------------------------------------
-
07-14-2006, 09:22 AM #2803QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
nope it doesnt work on my psp but my psp is fw 2.6 (coz no-one i know has fw1.5
)
-
07-15-2006, 06:32 AM #2804QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
hey is there anything wrong with this code because when i run it it just freezes but everything shows.
code:Code:white = Color.new(255,255,255) red = Color.new(255,0,0) menu = Image.load("images/menu.png") menuselect = 0 while true do screen:clear() pad = Controls.read() screen:blit(0,0,menu) if pad:up() then menuselect = menuselect - 1 end if pad:down() then menuselect = menuselect + 1 end if menuselect == -1 then menuselect = 1 end if menuselect == 2 then menuslect = 0 end if menuslect == 0 then screen:print(240,120,"Start",red) screen:print(240,150,"Quit",white) end if menuselect == 1 then screen:print(240,120,"Start",white) screen:print(240,150,"Quit",red) end screen.waitVblankStart() screen.flip() end
-
07-15-2006, 06:33 AM #2805sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
I don't thikn anything is wrong, it seems like the psp ran out of memory if it froze, but that wouldn't make sense.
-
07-15-2006, 06:35 AM #2806QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
no i used it on lua player windows and when i ran it it just wouldnt move and let me change the color of the text (i.e. the selector)
-
07-15-2006, 08:19 AM #2807
Try this:
Code:white = Color.new(255,255,255) red = Color.new(255,0,0) menu = Image.load("images/menu.png") menuselect = 0 while true do screen:clear() pad = Controls.read() screen:blit(0,0,menu) if pad:up() then menuselect = menuselect - 1 end if pad:down() then menuselect = menuselect + 1 end if menuselect < 0 then menuselect = 1 end if menuselect > 1 then menuselect = 0 --you forgot an "e" here end if menuselect == 0 then -- here aswell screen:print(240,120,"Start",red) screen:print(240,150,"Quit",white) end if menuselect == 1 then screen:print(240,120,"Start",white) screen:print(240,150,"Quit",red) end screen.waitVblankStart() screen.flip() endLUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
07-15-2006, 09:48 AM #2808QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
thnx its works (mostly) lol
-
07-15-2006, 12:31 PM #2809QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Illinois
- Beiträge
- 897
- Points
- 8.215
- Level
- 61
- Downloads
- 0
- Uploads
- 0
http://www.sendspace.com/file/4jg6xl
Can someone take a look at my code. There is a problem with putting the animation on the screen.Geändert von cwirsing (07-15-2006 um 01:28 PM Uhr)
-
07-15-2006, 12:58 PM #2810QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
Hey does anyone know how to do animation. Like when you are using a sprite sheet
Geändert von mark.sparky (07-15-2006 um 01:49 PM Uhr)
-
07-17-2006, 10:14 AM #2811
someone told me to use this code to make a player controlled player pop up but not sure if i can get it too work
player{}
player.x
player = image.load("player.png")
controls.red()
If pad:right then
player.x = player.x + 5
end
if pad:left then
player.x = player.x -5
end
-
07-17-2006, 10:24 AM #2812I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
That isn't the entire code, he's just showing you an example. A complete code would be:
You can copy and paste this code it works. But you have to take out the spaces it puts in at line 9.Code:blue = Color.new(0,0,255) player = Image.createEmpty(20,20) --creates a block 20 pixels by 20 pixels player:clear(blue) -- colors the block blue Player = {} Player = {x = 460, y = 252} -- x and y coordinates of block while true do pad = Controls.read() screen:clear() screen:blit(Player.x,Player.y,player) --blits block to the screen if pad:left() then Player.x = Player.x - 2 end if pad:right() then Player.x = Player.x + 2 end screen.waitVblankStart() screen.flip() end
-
07-17-2006, 10:33 AM #2813
Ok thanks a lot this wil really helpo me out a lot!
Double Post Merge
what about up and down/
Double Post Merge
i want a specified picture as the blue block also
-
07-17-2006, 10:36 AM #2814I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
Ffor up and down add this under right and left:
Zitat von Bob Hoil
For a picture, just delete these line:Code:if pad:up() then Player.y = Player.y - 2 end if pad:down() then Player.y = Player.y + 2 end
and add this lineCode:player = Image.createEmpty(20,20) --creates a block 20 pixels by 20 pixels player:clear(blue) -- colors the block blue
Code:player = Image.load("YourImage.PNG")
-
07-17-2006, 10:47 AM #2815
now i need too now how to set boundries and add enemy's the tutorials don't explain very well
-
07-17-2006, 10:58 AM #2816I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
To ad boundries just put these lines in:
To add enemies you need to know some Artificial Intelligence, which I don't think you're that far yet. But if you want to know PM me and I can try to help you.Code:if Player.x > 460 then -- this number will change if your character size is larger Player.x = 460 --or smaller than 20 end if Player.x < 0 then Player.x = 0 end if Player.y > 252 then -- again this number will change Player.y = 252 end if Player.y < 0 then Player.y = 0 end
BTW- Use Evilmana.com for tutorials, they're really easy.
-
07-17-2006, 11:08 AM #2817sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
adding enemy (that can control them selves a.k.a AI) is very difficult.
-
07-17-2006, 11:09 AM #2818I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
Depending on how intelligent the enimies are, it can be simple. Like I said you can PM me for help, or just post here and we'll try to help as much as possible.

-
07-17-2006, 11:11 AM #2819sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
yeah could be as simple as this.
that way the enemy just follows the characterCode:if player.x < enemy.x then enemy.x = enemy.x -5 end if player.x > enemy.x then enemy.x = enemy.x +5 end
-
07-17-2006, 11:14 AM #2820I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
That's how most games do it. Then soon as the enemy touches the character the health drops by 5. But it could be VERY complicated.



LinkBack URL
About LinkBacks
Mit Zitat antworten

Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum