forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

I need SPEED!!! (source files included)

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
skar



Joined: 20 Sep 2005
Posts: 6

PostPosted: Tue Sep 20, 2005 10:00 am    Post subject: I need SPEED!!! (source files included) Reply with quote

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[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
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


(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![img][/img]


Last edited by skar on Tue Sep 20, 2005 7:25 pm; edited 2 times in total
Back to top
View user's profile Send private message
Giuliano



Joined: 13 Sep 2005
Posts: 78

PostPosted: Tue Sep 20, 2005 10:09 am    Post subject: Reply with quote

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..
Back to top
View user's profile Send private message
skar



Joined: 20 Sep 2005
Posts: 6

PostPosted: Tue Sep 20, 2005 10:27 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Giuliano



Joined: 13 Sep 2005
Posts: 78

PostPosted: Tue Sep 20, 2005 12:28 pm    Post subject: Reply with quote

Yes, blit is slow and blitting too much will slow down the game. The thing about Blit (as seen in the other thread) is that what makes it slower is calling it many times, not the size of the image.

If you post some code we can see if it's the code or the blit that is being slow.
Back to top
View user's profile Send private message
skar



Joined: 20 Sep 2005
Posts: 6

PostPosted: Tue Sep 20, 2005 5:37 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Tue Sep 20, 2005 10:42 pm    Post subject: Reply with quote

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)

Code:

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

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
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
skar



Joined: 20 Sep 2005
Posts: 6

PostPosted: Wed Sep 21, 2005 12:16 am    Post subject: Reply with quote

Thanx you all...for your support, this forum is doing very well.

I will keep improve my code, with less blits and try your good ideas and I will come back later with a better code.


PROBLEM RESOLVED THREAD SCROLLING IDEA...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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