|
#41
|
||||
|
||||
|
Ok this isnīt really a code fragment but its a tip:
If you draw an image with the screen.fillrect memory it takes more memory thanusing an compremize image: I have tested it with an rectangle in black... |
|
|
|||
|
|
|
#42
|
||||
|
||||
|
So redrawing a 240*400 image takes less than a 240*400 filled square? Sounds odd... Might only be applicable for one colored stuff, had lots of trouble with redrawing to get it smooth in my Paradise Slots where I use images. Though, I use several layers of them..
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it! Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it. Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^ |
|
#43
|
||||
|
||||
|
I havenīt test it yet, but I have test it with a small 100x100 black image. I have save this image with Photoshop as an compremize image.
|
|
#44
|
||||
|
||||
|
Because there is still the "draw at negative coordinates" bug which presumably causes the player to shut down, I had an idea to write a function safeDraw which would handle the negative coordinates for you and actually crop the image automatically.
I think it's a good solution when you have lots of moving objects that often slide off the screen and you don't want to make checks every time. Code:
function image:safeDraw(x,y)
local l,t=x,y
local ox,oy=0,0
local crop=false
if x<0 then
ox=-x
l=0
crop=true
elseif x+self:width()>screen.width() then
ox=x+self:width()-screen.width()
crop=true
end
if y<0 then
oy=-y
t=0
crop=true
elseif y+self:height()>screen.height() then
oy=y+self:height()-screen.height()
crop=true
end
if crop then
return self:draw(x,y,l,t,self:width()-ox,self:height()-oy)
else
return self:draw(x,y)
end
end
__________________
There was a little man... Last edited by Nohajc; 02-03-2011 at 04:43 AM. |
|
#45
|
||||
|
||||
|
I had to edit the function a bit, since it was slowing things down and also I did not take to account pictures that are off screen at right or bottom.
So, an updated version above.
__________________
There was a little man... |
|
#46
|
||||
|
||||
|
Yes now it works right
|
|
#47
|
||||
|
||||
|
This code is helpfull for realtime saves weather in rpg's,puzzles,fast paced action games
Here is a table to file code: Right now it will only work with tables in this format: ( i plan on updating my function to handle all types of tables) example[1].x = 315 example[1].y = 95 example[1].maxx = 21 example[1].maxy = 28 example[2].x = 315 example[2].y = 95 example[2].maxx = 21 example[2].maxy = 28 e.c.t. tbl= the table you want to save savename=the name you want your table to be saved as filename=the file you want to save to subtables= the number of smaller tables in on section of a table ie: in the example above there is 4 Code:
function table_save(tbl,savename,filename,subtables)
local passes=0
local charS,charE = " ","\n"
file,err = io.open( filename, "w" )
local tables,lookup = { tbl },{ tbl }
file:write( savename .. " = {{}")
for i=2, #tbl do
file:write(",{}")
end
file:write("}")
for idx,t in ipairs( tables ) do
local thandled = {}
for i,v in ipairs( t ) do
thandled[i] = true
if type( v ) == "table" then
if not lookup[v] then
table.insert( tables, v )
lookup[v] = #tables
end
else
local value = ( type( v ) == "string" and exportstring( v ) ) or tostring( v )
end
end
for i,v in pairs( t ) do
if (not thandled[i]) then
if type( i ) == "table" then
if not lookup[i] then
table.insert(tables,i)
lookup[i] = #tables
end
else
passes=passes+1
currentsubtable=math.ceil(passes/subtables)
local index = ( type( i ) == "string" and savename.."["..currentsubtable.."]"..".".. i ) or string.format( "[%d]",i )
-- penguins style table
file:write(index.."=" )
end
if type( v ) == "table" then
if not lookup[v] then
table.insert( tables,v )
lookup[v] = #tables
end
else
local value = ( type( v ) == "string" and exportstring( v ) ) or tostring( v )
file:write( value..charE )
end
end
end
file:write(charE )
end
file:close()
end
Usage Code:
function table_save(example,"example","save.lua",4)
__________________
Tools: Playlist Manager , Document to RSS , Notepad++ Instellisense Games/Apps: Asteroids, ZenFrame, Graphing Calculator, Pingus X-Fi2, Boxwars, SkiFree, Jezzball Last edited by jbob182; 02-12-2011 at 01:13 PM. |
|
#48
|
||||
|
||||
|
Here is a function for on player debugging
Quote:
Usuage: Code:
debug_player(animations)
__________________
Tools: Playlist Manager , Document to RSS , Notepad++ Instellisense Games/Apps: Asteroids, ZenFrame, Graphing Calculator, Pingus X-Fi2, Boxwars, SkiFree, Jezzball |
|
#49
|
|||
|
|||
|
This is a PSP lua common code snippets page:
http://forums.qj.net/psp-development...-snippets.html maybe something on here will help coding:-)
__________________
Apps: Guitar Tuner- http://anythingbutipod.com/forum/showthread.php?t=61049 |
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 01:25 PM.












Linear Mode
