Hello guys,
First of all thank you for Lua and this great forum, we learn a lot and Lua is very easy to use...
BUT I have got a problem:SPEED.
I start to develop a ARMOR ALLEY clone on PSP with Lua.
First Screenshot (start development phase)
Everything go easy but now as I load more than 30 images and I use this kind of for:
for i = 1,mtf do
for j=1,etf do
if (et[j]-mt)<5 and (et[j]-mt)>0 then
if math.random(2)==2 then
table.insert(dmt,i)
else
table.insert(det,j)
end
end
end
for j=1,eff do
if (ef[j]-mt)<5 and (ef[j]-mt)>0 then
if math.random(5)==5 then
table.insert(dmt,i)
else
table.insert(def,j)
end
end
end
end
(sorry for the code) my pSP with Lua is too slow and so the game is not playable...
Do you think the slow speed is caused by the images loaded, the "fors" instructions or my bullshit code?
If someone has find a solution to accelerate Lua language or Lua player please help me...
(If you want I can give you the code of my ARMOR ALLEY clone)
Thank you and god save PS2DEV!
I need SPEED!!! (source files included)
Moderators: Shine, Insert_witty_name
I need SPEED!!! (source files included)
Last edited by skar on Tue Sep 20, 2005 7:25 pm, edited 2 times in total.
well you should only load your images at the start of your game.. you could make a loading screen for that.. if the game is being slow during game play then it's the way you draw or process your data..
I don't know if your game uses tiles or not but if it does.. read my I/O File handling thread .. it got a bit off topic and discussed that..
I don't know if your game uses tiles or not but if it does.. read my I/O File handling thread .. it got a bit off topic and discussed that..
Thanx Giuliano but I don't use tiles or I/O instructions.
I know that loading images is in the START of the game and not after I was saying that I have more than 30 or 40 blits each flip because all the vehicles of the game are IMAGES blits moving on a slide background of 960 pixels long (2 backgrounds images)...
I don't know if the way I code the game is wrong (I don't have a past experience in game development) but I would like to know if too much blits slow down the game or too much "for" or intertwined instructions (probably badly coded) slow down the game?
Maybe it is better to draw a line or a pack of pixel than to use a blit? I don't know.
Perhaps it is better not to use math.random() or for instructions intertwined?
But thank you for your response I will read your thread on I/O file handling.
I know that loading images is in the START of the game and not after I was saying that I have more than 30 or 40 blits each flip because all the vehicles of the game are IMAGES blits moving on a slide background of 960 pixels long (2 backgrounds images)...
I don't know if the way I code the game is wrong (I don't have a past experience in game development) but I would like to know if too much blits slow down the game or too much "for" or intertwined instructions (probably badly coded) slow down the game?
Maybe it is better to draw a line or a pack of pixel than to use a blit? I don't know.
Perhaps it is better not to use math.random() or for instructions intertwined?
But thank you for your response I will read your thread on I/O file handling.
OK I understand I will try to use one image and a specified blit on this image that will surely speed up my code...
Thank you Arwin and Giuliani for your support...
Here is a zip with my source files:
http://www.savefile.com/files3.php?fid=8846088
Perhaps I my problem is this: as the goal of this game is to scroll a landscape of 960 pixels long I didn't load a 960 pixels image because it is impossible with Lua but I used this code:
screen:blit(0, 0, background, xk, 0, 480, 272, false)
As my image is 512 px long with xk increasing when I reach the end of the image a next one appear (in fact the same) without coding anything else. I keep this discovery to scroll along my game without creating a particular scrolling engine as some developers. But I am not sure this is good for speed.
Thank you Arwin and Giuliani for your support...
Here is a zip with my source files:
http://www.savefile.com/files3.php?fid=8846088
Perhaps I my problem is this: as the goal of this game is to scroll a landscape of 960 pixels long I didn't load a 960 pixels image because it is impossible with Lua but I used this code:
screen:blit(0, 0, background, xk, 0, 480, 272, false)
As my image is 512 px long with xk increasing when I reach the end of the image a next one appear (in fact the same) without coding anything else. I keep this discovery to scroll along my game without creating a particular scrolling engine as some developers. But I am not sure this is good for speed.
speedowns:
blitting stuff that is not needed (why blit ~900x272px) when you only see 480 in width of em?!
have a look over your code and see where you can optimize it (for sure you can find something in 90% of your cases)
what is this code supposed to do?
(comments and variable names with a meaning would help)
note:
1) optimizing is not always removing lines of code
2) (my bomberman-game uses far mor blits than 40 and works smoothly! (the field alone is 15x29blits!))
3) you may have a look on the sidescrolling-idea-code which uses an image of 1500px (but only blits 480px) [although there is a little bug somewhere in the code]
greets
lumo
willed to help, but get us to a starting point
blitting stuff that is not needed (why blit ~900x272px) when you only see 480 in width of em?!
have a look over your code and see where you can optimize it (for sure you can find something in 90% of your cases)
Code: Select all
for i = 1,mtf do
for j=1,etf do
if (et[j]-mt[i])<5 and (et[j]-mt[i])>0 then
if math.random(2)==2 then
table.insert(dmt,i)
else
table.insert(det,j)
end
end
end --end for etf
for j=1,eff do
if (ef[j]-mt[i])<5 and (ef[j]-mt[i])>0 then
if math.random(5)==5 then
table.insert(dmt,i)
else
table.insert(def,j)
end
end
end --end for eff
end --end for mtf
(comments and variable names with a meaning would help)
note:
1) optimizing is not always removing lines of code
2) (my bomberman-game uses far mor blits than 40 and works smoothly! (the field alone is 15x29blits!))
3) you may have a look on the sidescrolling-idea-code which uses an image of 1500px (but only blits 480px) [although there is a little bug somewhere in the code]
greets
lumo
willed to help, but get us to a starting point