at work. ;)Why not just try it? :P
looks like (from Shine's eg) that you can quite happily blit well offscreen, though, which is useful.
Moderators: Shine, Insert_witty_name
I don't quite see what that function would be good for - in my opinion, on startup, _ALL_ .zipfiles can be added to the path, so there is no need to open archives from within scripts yourself. Not having an extra functions should be easier for users.Shine wrote: - System.openArchive(name) is added, which adds all files from the archive for all read functions (I omitted the nasty details here, like rewriting Lua io-lib and Mikmod to make this possible :-)
I'd say: add all found archives to the path. The archives should have a subfolder for the game (so in mygame.zip, there would be mygame/index.lua).Shine wrote: So the proposed changes to Lua Player:
- EBOOT.PBP first searchs for script.lua and starts it, if found
- if not found, it search for game.zip, opens it as a PhysicsFS archive and starts script.lua from within it
These functions & changes are imo only needed if not all archives are added at bootup.Shine wrote: - System.openArchive(name) is added, which adds all files from the archive for all read functions (I omitted the nasty details here, like rewriting Lua io-lib and Mikmod to make this possible :-)
- System.closeArchive(name) is added, for example for Lowser to find the index.lua from the currently opened archive, only
- Lowser scans the Applications directory for directories and for zip-archives
Yeah. /psp/GAME/luaplayer contains the binary, so that if you want to upgrade to a new version of luaplayer, you have to move all your files (Applications, Documents) somewhere else, remove the old version, put the new version in, and put all the files back. Plus, GAME is indeed for the binaries, and user files don't belong there. (That's like saving your Photoshop images to /Program Files/Photoshop/ or whatever.)Laurens wrote:As for the path, I think /psp/GAME/luaplayer would be better, or is there a reason you guys like /psp/luaplayer better?
You are right, no need for user functions for PhysFS archives, if all files with ".luapp" are opened as archives on startup. This can be recursive: If a script is called with the new script instantiate function call and it is in a normal directory, all archives within this directory are opened, too, which may be useful while developing, because you can place your graphics in one file in the directory, but you can still editing the script file(s).Laurens wrote:These functions & changes are imo only needed if not all archives are added at bootup.
make sure you got it like this:alexmae wrote:how can i make it work if 2 keys are pressed at the same time? it only gets one
Code: Select all
pad = Controls.read()
if pad:cross() then
etc
end
if pad:circle() then
etc
end
Code: Select all
pad = Controls.read()
if pad:cross() then
etc
elseif pad:circle() then
etc
end
Results for me:System.usbDiskModeActivate()
color = {
red = Color.new(255,0,0);
green = Color.new(0, 255, 0);
blue = Color.new(0,0,255);
}
local q = 0
local j = 0
local time = os.clock()
for i=1,100000 do
q = q +1
end
local time2 = os.clock()
local delay = time2 - time
screen:print(10, 40, "for loop: " .. tostring(delay) .. " milliseconds", color.red)
screen:print(10, 50, "|_iterations : " .. tostring(q), color.red)
local q = 0
local i = 0
local j = 100000
local time = os.clock()
while i < j do
i = i +1
q = q +1
end
local time2 = os.clock()
local delay = time2 - time
screen:print(10, 60, "while + loop: " .. tostring(delay) .. " milliseconds", color.green)
screen:print(10, 70, "|_iterations : " .. tostring(q), color.green)
local v = 0
local q = 0
local j = 100000
local time = os.clock()
while j > v do
j = j -1
q = q +1
end
local time2 = os.clock()
local delay = time2 - time
screen:print(10, 80, "while - loop: " .. tostring(delay) .. " milliseconds", color.blue)
screen:print(10, 90, "|_iterations : " .. tostring(q), color.blue)
while not Controls.read():start() do
screen.waitVblankStart()
screen.flip()
end
System.usbDiskModeDeactivate()
MikeHaggar wrote:make sure you got it like this:alexmae wrote:how can i make it work if 2 keys are pressed at the same time? it only gets onethanks alot ;)Code: Select all
pad = Controls.read() if pad:cross() then etc end if pad:circle() then etc end
and not:Code: Select all
pad = Controls.read() if pad:cross() then etc elseif pad:circle() then etc end
Code: Select all
-- Define Text Color
green = Color.new(0, 255, 0)
-- Load background Image
backimage = Image.load("background.png")
-- Print out text with pre-defined color
screen:print(240, 136, "Just Testing", green)
-- Display background Image
image:blit(0, 0, backimage, 0, 0, backimage:width(), backimage:height(), false)
screen.flip()
while true do
screen.waitVblankStart()
end
Um. Look at your code. First you print text to the screen. Then, you paint an image on top of that. Or actually, you're painting the image into nothing... It should be screen:blit(0,0,backimage, false) (the rest of the parameters are redundant)F34R wrote:I am just learning here, so excuse the noobness of this post lol. I am having trouble just displaying a backgroud behind my text. I've looked at the snake example, still having troubles... can anyone clarify what I am doing wrong here.
Code: Select all
-- Define Text Color green = Color.new(0, 255, 0) -- Load background Image backimage = Image.load("background.png") -- Print out text with pre-defined color screen:print(240, 136, "Just Testing", green) -- Display background Image image:blit(0, 0, backimage, 0, 0, backimage:width(), backimage:height(), false) screen.flip() while true do screen.waitVblankStart() end
Code: Select all
-- Define text colors
green = Color.new(0, 255, 0)
-- Load Images
background = Image.load("background.png")
splash = Image.load("luasplash.png")
-- Display Lua Splash
screen:blit(0, 0, splash, false)
screen.waitVblankStart()
screen.flip()
screen.waitVblankStart(240)
screen.flip()
-- Display Background Image
screen:blit(0, 0, background, false)
screen.waitVblankStart()
screen.flip()
screen.waitVblankStart(250)
screen.flip()
-- Print text on the screen
screen:print(200, 100, " DID IT WORK ? ", green)
screen.flip()
while true do
screen.waitVblankStart()
-- End
end
Is there any way to track key presses and releases?MikeHaggar wrote:make sure you got it like this:alexmae wrote:how can i make it work if 2 keys are pressed at the same time? it only gets oneCode: Select all
pad = Controls.read() if pad:cross() then etc end if pad:circle() then etc end
and not:Code: Select all
pad = Controls.read() if pad:cross() then etc elseif pad:circle() then etc end
Code: Select all
pad = Controls.read()
if pad:left() and pad ~= last_k then
--processed key left. prevent execution of code while key remains pressed
end
last_k = pad
Code: Select all
function rotate(image, dir)
local w = image:width()
local h = image:height()
local result = Image.createEmpty(h, w)
for x=0,w-1 do
for y=0,h-1 do
if dir == 0 then
result:pixel(h-y-1, x, image:pixel(x, y))
else
result:pixel(y, w-x-1, image:pixel(x, y))
end
end
end
return result
end
Code: Select all
tank = Image.load("tank.png")
--90° Clockwise:
tank = rotate(tank, 0)
screen:blit(0, 0, tank, 0, 0, tank:width(), tank:height(), false)
--90° Counter-Clockwise:
tank = rotate(tank, 1)
screen:blit(0, 0, tank, 0, 0, tank:width(), tank:height(), false)
It is not white, use a better graphics program.F34R wrote:Ok, another question. This one is about displaying a graphic, like the snake. I noticed that the background in the snake tileset is white. Does it HAVE to be white.
LOL. I was just viewing it in windows explorer. I opened it up in PS and I see that is has a transparent background. Ok, I admit, I am just shy of being retarded when it comes to this lol.Shine wrote:It is not white, use a better graphics program.F34R wrote:Ok, another question. This one is about displaying a graphic, like the snake. I noticed that the background in the snake tileset is white. Does it HAVE to be white.
Code: Select all
while pad:right() do
x = x + 2
end
Code: Select all
x = 20
y = 100
pad = Controls.read()
if pad:right() then
x = x + 10
end
if pad:left() then
x = x - 10
end
if pad:up() then
y = y - 10
end
if pad:down() then
y = y + 10
end
screen.blit(x, y, smiley)
screen.waitVblankStart()
screen.flip()
pad = Controls.read()
if pad:start() then
break
end
Things like this are the prerequisites for the Lua Player tutorial, I don't want to write a general Lua tutorial, there are better ones for this purpose, like http://lua-users.org/wiki/TutorialDirectorySnowSurfer wrote:nice tuts shine, i think one needs to be added about using a timer in a game to determine how much time is left until you get gameover.. :)
Wow, you really need to review the tutorials and focus on basic programming with lua...F34R wrote:Ok, I have my little smiley going left, right, up, and down. Here is what i cant figure out...
When I press "right", my smiley moves to the right, but it only moves ONCE. When I stop pressing "right" on the dpad, the smiley moves back to its original position. How do I make it stay on the new position ? I tried doing a while loop, and it locked the psp up hehe..
This only made the smiley move in the direction pressed, then put the smiley back to the original x/y position.
Code: Select all
x = 20
y = 100
while true do
pad = Controls.read()
if pad:right() then
x = x + 10
end
if pad:left() then
...blah blah blah
end
Code: Select all
System.usbDiskModeActivate()
background = Image.load("background.png")
smiley = Image.load("smiley.png")
while true do
screen:blit(0, 0, background, 0, 0, background:width(), background:height(), false)
-- Set start position for the smiley
x = 221
y = 135
-- Set postition when dpad is pressed
while true do
pad = Controls.read()
if pad:right() then
x = x + 5
end
if pad:left() then
x = x - 5
end
if pad:up() then
y = y - 5
end
if pad:down() then
y = y + 5
end
end
screen:blit(x, y, smiley)
screen.waitVblankStart()
screen.flip()
if pad:start() then
break
end
end
Code: Select all
System.usbDiskModeActivate()
background = Image.load("background.png")
smiley = Image.load("smiley.png")
screen:blit(0, 0, background, 0, 0, background:width(), background:height(), false)
-- Set start position for the smiley
x = 221
y = 135
-- Set postition when dpad is pressed
function keypad()
local pad = Controls.read()
if pad:right() then
x = x + 5
elseif pad:left() then
x = x - 5
elseif pad:up() then
y = y - 5
elseif pad:down() then
y = y + 5
end
end
while not Controls.read():start() do
keypad()
screen:blit(x, y, smiley)
screen.waitVblankStart()
screen.flip()
end