QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

[release] my mod of lua animLib v4 now v0.3 maybe last

This is a discussion on [release] my mod of lua animLib v4 now v0.3 maybe last within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Hi, Here's my 2nd lua library, in fact a mod of an existing library: animLib v4 by Grimfate126. I changed ...

Reply
 
LinkBack Thread Tools
Old 04-17-2007, 01:46 AM   #1


Developer
 
daaa57150's Avatar
 
Join Date: Sep 2006
Location: france
Posts: 167
Trader Feedback: 0
Default [release] my mod of lua animLib v4 now v0.3 maybe last

Hi,

Here's my 2nd lua library, in fact a mod of an existing library: animLib v4 by Grimfate126.
I changed a lot of things, and added also a lot, mainly image buffering so that animations share common image ressources.

For those who don't know animLib, this allows you to easily create animations based on multiple images or on spritesheets.

And for those who use animLib and wish to change for this mod, I'm sorry but you'll have to rewrite parts of your code because I changed a lot of things. But I think it's worth the -little- trouble.

As it's the first release and although I tested it intensively, there may be bugs or things missing or things you wouldn't expect to behave like it does... If it's the case report it there.

I'm developping a game with it and for the moment it does what I need in a great way.

I included a long readme with explanations for everything and an index.lua which will create a bunch of animations and show you how to do things.

Here is the file:
animLib daaa's mod v0.1
animLib daaa's mod v0.2 (only added width() and height() function to smoothly replace your images in your code)
animLib daaa's mod v0.3

Spoiler for readme.txt:
This is the readme for my mod (daaa's mod) of
Grimfate126's "animlib" in lua, currently version 0.1,
first release.

If you need help, look for the release thread in the
QJ forums, or drop me a PM, I'm daaa57150 there. But
before, look at this tutorial and at the index.lua
it should be easy.
You can also send me a mail at daaa57150@gmail.com but
I'll answer really slowly there.

Please if you use it, give me and Grimfate126 credit
somewhere.

daaa.



1) WHAT DOES THIS LIBRARY DO:
This allows you to create animation objects based on
spritesheets or multiple images, for your lua scripts.
It buffers the pictures if you have many copy of the same
animation, and can keep them (the pictures) in memory even if
they are destroyed in the case you want to create a copy of
the animation later.
The animations are customizable in speed and loop numbers,
independently from each other. Playback can be started, paused,
resumed, resetted. Many utility functions are also available to
get or set some properties (isRunning, nbImages etc...).

2) WHAT DOESN'T THIS LIBRARY DO:
- It's not precise on the time, you can have 2 same animations
and start them at the exact same time, and still see one go
faster. If you want sync'ed animations, you'll need to find a
way yourself.
- Does not permit to have the same image multiple times in the
same animation, for the moment at least.
- Does not permit to have delay variations in the animation,
each frame is separated from the previous one by the same
amount of time.
- Contrary to what Grimfate said, there seem to be a limitation
with the spritesheets, sizewise.


3) WHAT'S DIFFERENT FROM ANIMLIB V4:
- No more distinction between spritesheets and multiple images
animations, exept during creation of course. This allows you
to have tables with a mix of the 2 kinds, and calling the exact
same function on all items without caring anymore.
- Loops limitation and speed are set during construction, and
not parameterized during blitting. This can be altered with
setter methods on the object. So there is no more advancedBlit().
- Blit functions require a target, usually you'll do it on the
'screen' var but you may want to blit it on an image, so it's
possible now.
- I removed garbage collection from the library, you'll have to
call it when appropriate. This is so it's not called multiple
times in a freeing loop for example.
- Images used in animations are buffered, so if you have many
animations based on the same images, they won't be loaded as
many times as you have animations, but will be shared amongst
them. There are also some memory functions to allow you to
prebuffer the images you'll need, and ask them to stay in
memory even if no more animation uses them. This will allow you
to create an animation based on them later, without loading. By
default, they are shared but will be unloaded once no animation
need them anymore.
- Animations don't start automatically, you'll have to call the
start method.
- Certainly other things I don't remember, I changed so many...


3) HOW TO INCLUDE THIS IN YOUR CODE:
Simply add this line at the beginning of your code:

dofile("animLibDaaa.lua")

and you'll be able to use my functions.

4) MEMORY MANAGEMENT
Images that the animations need are shared between all the
animations that need them. A reference based on the image
url is kept in memory to achieve this.
There are 2 modes available to manage this:

- By default, the first time an image is needed it is loaded
and your animation will use it. Further animations you create
that need that image will simply use the one already loaded.
If all your animations are freed, so none needs the image
anymore, the library will unload the image automatically. So
you'll always have the max memory possible available. The
counterpart for this is that if you need that image again,
the library will need to reload it.

- In the second mode, the first time an image is needed it is
loaded and your animation will use it. Further animations you
create that need that image will simply use the one already
loaded. If all your animations are freed, so none needs the
image anymore, it is kept in memory. So next time you create
an animation that needs it, you'll experience no loading. The
counterpart of this is that you'll have to manage the images
you keep in memory and force unloading yourself when appropriate.
There are many functions that help you doing this easily.
Look in the index.lua file for an example.

This behaviour is set per image, so you can have some that
behave in a way and some the other way.
To change from one mode to the other use those 2 functions:
ANIM.setDefaultMemoryMode ToAlwaysFree(): free as soon as possible
ANIM.setDefaultMemoryMode ToBuffer(): keep in memory
This will affect further image loadings (ie: new animation creations).
You can preload images before image creation by using this
function:
ANIM.bufferImage(file)
this will put this specific image in the second mode and load it.

WARNING:
For this to work, ie the images references counters to be
always correct, you have to call the free method on your
animations! This is important! If you don't you'll end up
with all the images staying in memory (one copy), and maybe
animations with references on images that are non-existent.

To "unbuffer" an image, call the function
ANIM.freeImage(file)
This will mark it to be at mode 1 (default), ie the image will
be unloded from memory as soon as it is not referenced anymore.
When calling this function, if there are already no reference
to this image, it is unloaded directly.

Note that in my code there are no calls to collectgarbage().
You'll have to call it when you see fit.

I'm using mode 2 in my index.lua file, read it to understand
this. Comment the line that says:
ANIM.setDefaultMemoryMode ToBuffer()
to let it be at mode 1, and start the program to see the
difference. You should see the psp load images on the MS on
the first creation of an animation.





5) MEMORY FUNCTIONS:
-------------------------------------------------------------
ANIM.setDefaultMemoryMode ToAlwaysFree()
-------------------------------------------------------------
Sets the default memory mode to favor memory, ie the images
will be unloaded from memory as soon as no animation needs
them anymore. This applies to subsequent images loading, ie
during the construction of a new animation that needs an
image not already loaded.
Images already in memory are not affected.

-------------------------------------------------------------
ANIM.setDefaultMemoryMode ToBuffer()
-------------------------------------------------------------
Sets the default memory mode to favor speed, ie the images
will stay in memory even if no animation needs them. You will
have to unload them with the freeImage function. his applies
to subsequent images loading, ie during the construction of
a new animation that needs an image not already loaded.
Images already in memory are not affected.

-------------------------------------------------------------
ANIM.bufferImage(file)
-------------------------------------------------------------
Pre-buffers an image, so it is already in memory when you'll
create animations. The memory mode is set to buffer mode for
this image.
"file" is the path to the image to buffer.

-------------------------------------------------------------
ANIM.freeImage(file)
-------------------------------------------------------------
Unloads an image from memory if no animation references it,
or marks it to be in mode 1 so that it is unloaded as soon as
no animation references it anymore.
"file" is the path to the image to delete.

-------------------------------------------------------------
ANIM.freeAllImages()
-------------------------------------------------------------
Same as the function above, but for all the images that the
library has loaded.



6) CREATOR FUNCTIONS
-------------------------------------------------------------
ANIM.newMultImgAnim(nbIma ges, header, extension, where, delay, maxLoops)
-------------------------------------------------------------
Creates a new animation, based on multiple images. Those
images need to be at the same place on the filesystem and be
named the same way with a number at the end, like this:
"<header><number>.<extens ion>"
for example "my_image_4.png".

nbImages: number of images your animation is composed of.
header: beginning of the name of your images.
extension: the extension of your images ("png" or "jpg").
where: folder where they are. Must end with a "/", or can be
equal to "" or be nil (which will make it equal to "").
delay: time separating 2 frames, in ms.
maxLoops: tells how many loops the animation does before
stopping on the last frame. Leave it nil for endless looping.


-------------------------------------------------------------
ANIM.newSpriteSheetAnim(f ile, nWidth, nHeight, delay, maxLoops)
-------------------------------------------------------------
Creates a new animation, based on a spritesheet.
file: path to your spritesheet image
nWidth: width in pixels of one frame in this image.
nHeight: height in pixels of one frame in this image.
delay: time separating 2 frames, in ms.
maxLoops: tells how many loops the animation does before
stopping on the last frame. Leave it nil for endless looping.


7) METHODS
Call them like this:
myAnimation:theMethod(par ams)

-------------------------------------------------------------
blit(target, x, y)
-------------------------------------------------------------
Blits the animation on the target.
target: the image on which to blit the animation, "screen" for
example.
x, y: coordinates where to blit it.


-------------------------------------------------------------
getImage(num)
-------------------------------------------------------------
Returns the nth image in the animation, an Image object. This
object is either the image in memory for multImg animations,
or a newly created image cut in the spritesheet for
spritesheet animations. Thus the uneffectiveness of this
method with spritesheets.
When no parameter is given, the 1st image is returned for
multiple images animations, and the whole spritesheet image
for the spritesheets.
It is certainly a bad idea to use this method anyway, but
it's here in case you need it.
Note that you may loose transparency in the process for
spritesheet animations (only semi transparent pixels), this
is a bug of luaplayer.


-------------------------------------------------------------
reset(num)
-------------------------------------------------------------
Resets the animation to the frame number "num", or the first
if no arg is supplied.
The animation will continue running if it was or stay paused
if it was.
num: the frame num where the animation should go. Only
positive numbers allowed, and not 0. It starts at 1. It can
be greater to the total frame number of the animation, this
will simply get to the asked frame as if loops have been made
but the loop counter won't change.
By default it goes to the first frame.


-------------------------------------------------------------
pause()
-------------------------------------------------------------
Pauses the animation. If it is already paused, it has no
effect.


-------------------------------------------------------------
resume()
-------------------------------------------------------------
Resumes the animation, ie makes it run from where it is. If
the animation is already running it has no effect.


-------------------------------------------------------------
start()
-------------------------------------------------------------
Starts the animation from the beginning, the loop counter
is also resetted.


-------------------------------------------------------------
free()
-------------------------------------------------------------
Frees the animation, ie the object, and also the images if
they are not referenced from another animation and the memory
management for them favors memory over speed.
If speed is favored, even when there are no more references
on them they stay in memory, and you have to free them with
ANIM.freeImage(file)


-------------------------------------------------------------
isRunning()
-------------------------------------------------------------
Returns true if the animation is running, false otherwise.


-------------------------------------------------------------
isPaused()
-------------------------------------------------------------
Returns true if the animation is paused, false otherwise.


-------------------------------------------------------------
finishedLooping(n)
-------------------------------------------------------------
Returns true if it has made n loops already, this is true if
it has made more, or if it has reached the last frame of the
nth loop.
n: the number of loops the animation must have finished.


-------------------------------------------------------------
setDelay(delay)
-------------------------------------------------------------
Changes the interval time between frames for this animation.
delay: the delay between 2 frames, in ms.


-------------------------------------------------------------
resetLoop()
-------------------------------------------------------------
Puts the loop counter at the beginning, ie 1.


-------------------------------------------------------------
getTime()
-------------------------------------------------------------
Returns the timer's time. This is the time from the last frame
change (or the beginning if no frame change occured). This is
NOT the time the animation is running, or from it's creation.


-------------------------------------------------------------
getFrame()
-------------------------------------------------------------
Returns the current frame number.


-------------------------------------------------------------
getLoops()
-------------------------------------------------------------
Returns the current loop number.


-------------------------------------------------------------
getRow()
-------------------------------------------------------------
Returns the current row, might be useful for spritesheet
animations, always returns 1 for multiple images animations.
Row count starts at 1.


-------------------------------------------------------------
getColumn()
-------------------------------------------------------------
Returns the current column, might be useful for spritesheet
animations, always returns 1 for multiple images animations.
Column count starts at 1.


-------------------------------------------------------------
setProp(prop)
-------------------------------------------------------------
This is a utility function, here as a way for you to attach
a property (can be a table of properties) to the animation,
like a name or id for example.
Get it again with getProp().


-------------------------------------------------------------
getProp()
-------------------------------------------------------------
This is a utility function, here as a way for you to get
a property (can be a table of properties) you attached to
the animation, like a name or id for example.
Set it with setProp().


-------------------------------------------------------------
getType()
-------------------------------------------------------------
Returns the type of animation it is, spritesheet or multiple
images. So it either returns:
ANIM.TYPE_MULTIMG if it's a multiple images animation
or
ANIM.TYPE_SS if it's a spritesheet animation


-------------------------------------------------------------
getMaxLoops()
-------------------------------------------------------------
Returns the max loop number the animation was told to do when
created or when changed with setMaxLoops.


-------------------------------------------------------------
setMaxLoops(maxLoops)
-------------------------------------------------------------
Sets the maximum number of loops the animation must do before
stopping on the last frame. This won't make it run again if
it was stopped because it reached the max loop already.


-------------------------------------------------------------
getNbPictures()
-------------------------------------------------------------
Returns the number of images the animation is composed of. It
always returns 1 for spritesheet animations. This is not the
same as getNbFrames().


-------------------------------------------------------------
getNbFrames()
-------------------------------------------------------------
Returns the number of frames in the animation. This is
different from getNbPictures for spritesheets.


-------------------------------------------------------------
getImageName(num)
-------------------------------------------------------------
Returns the name of the image number num in the animation.
If no arg is submitted, this returns the name of the first
image. For spritesheet animations it always returns the name
of the spritesheet image, as it's the only one.


-------------------------------------------------------------
unbufferImages()
-------------------------------------------------------------
Calls ANIM.freeImage() on each image the animation is
composed of.
Call this if you want to unbuffer the ressources attached to
this animation, so that when no copy exists anymore, the
images are freed from memory.
If you used the default mode for the memory ie you called
ANIM.setDefaultMemoryMode ToAlwaysFree()
or didn't call
ANIM.setDefaultMemoryMode ToBuffer()
and
ANIM.bufferImage(file)
for an image in this animation, this won't have any effect as
everything is cleaned automatically when you'll call the
free() method on the animation.



7) PAY ATTENTION TO THIS
- always call the free method on your animations
- be coherent in the file names you pass as params to the
functions.
"images/myimage.png", "./images/myimage.png" may describe the
same image, but the library will consider them beeing 2
different images! so choose which you prefer and stick to it.



8)INDEX.LUA:
This file creates, destroys, blits animations of the 2 types
(spritesheets: Alucard and multiple images animations: Richter).
It uses mode 2 for memory management, ie if no images are
in memory and no animation uses it, it stays here.
You can change this behaviour by commenting the line
ANIM.setDefaultMemoryMode ToBuffer()
If you do so, you may see that when you delete all Alucards or
all Richters, and create on again, it will need a loading again.
Press cross to create a new Richter, circle to create a new
Alucard. Square erases the last created, without explicitely
unbuffering the images. You can add up to 56 animations, for
a total of 61 animations (4 buttons and the cursor). This will
make the PSP lag a bit around 20 animations I think.
Triangle pauses all the Alucards and Richters animations.
There is a cursor available, move it on the animations with
the DPad, and see the details at the bottom of the screen,
I tried to call as many functions as possible.



9) CONTACT
If you have some questions, think I should add or modify
something or simply want to tell me something, feel free to contact me.
The best way is on the QJ forums, in the release thread, or
by PM (I'm daaa57150). You can also reach me at this mail address:
daaa57150@gmail.com but I don't go there often.

Oh and if you use this for a game, tell me!

daaa.
__________________
Try my latest game:
MEGA DROPS 2


Last edited by daaa57150; 05-03-2007 at 06:06 AM..
daaa57150 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-17-2007, 05:32 AM   #2
 
xpack's Avatar
 
Join Date: Aug 2006
Location: Under Your Bed
Posts: 3,084
Trader Feedback: 0
Default

This is great I was thinking of working on games.
xpack is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-17-2007, 10:25 AM   #3


Developer
 
daaa57150's Avatar
 
Join Date: Sep 2006
Location: france
Posts: 167
Trader Feedback: 0
Default

Quote:
Originally Posted by xpack
This is great I was thinking of working on games.
I hope my library will help you! If you use it, do not hesitate to tell me how you find it, and if I should change or add things.
__________________
Try my latest game:
MEGA DROPS 2

daaa57150 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-17-2007, 02:01 PM   #4

total-Z
 
youresam's Avatar
 
Join Date: Jul 2005
Location: texas
Posts: 2,803
Trader Feedback: 0
Default

This is great man thanks screen:blit doesnt work for me this will make everything so much easier its what everyone needs thanks again
__________________
牧来栠摩琠敨映汩獥
PSN: youresam
From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
youresam is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-17-2007, 04:23 PM   #5
 

 
Join Date: Feb 2007
Posts: 246
Trader Feedback: 0
Default

Nice, but how can I mod it to make this work:

Code:
function collision(obj1, obj2)
	if (obj1.x >= obj2.x or obj1.x + obj1.img:width() >= obj2.x)
		and (obj1.x <= obj2.x + obj2.img:width() or obj1.x <= obj2.x + obj2.img:width())then
		if (obj1.y >= obj2.y or obj1.y + obj1.img:height() >= obj2.y)
			and (obj1.y <= obj2.y + obj2.img:height() or obj1.y + obj1.img:height() <= obj2.y + obj2.img:height()) then
			return true
		end
	else
		return false
	end
end
This function works if the tables passed to it contain regular images. I know I could probably write separate collision functions, one for the standard sprites, one for the animated sprites, and one for mixed standard/animated sprites, but I'd prefer to be able use this function as a universal collision tester so that it will still work if one or both of the objects have the .img part as an animation.
Merick is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-18-2007, 12:06 AM   #6


Developer
 
daaa57150's Avatar
 
Join Date: Sep 2006
Location: france
Posts: 167
Trader Feedback: 0
Default

Quote:
Originally Posted by Merick
Nice, but how can I mod it to make this work:

Code:
function collision(obj1, obj2)
	if (obj1.x >= obj2.x or obj1.x + obj1.img:width() >= obj2.x)
		and (obj1.x <= obj2.x + obj2.img:width() or obj1.x <= obj2.x + obj2.img:width())then
		if (obj1.y >= obj2.y or obj1.y + obj1.img:height() >= obj2.y)
			and (obj1.y <= obj2.y + obj2.img:height() or obj1.y + obj1.img:height() <= obj2.y + obj2.img:height()) then
			return true
		end
	else
		return false
	end
end
This function works if the tables passed to it contain regular images. I know I could probably write separate collision functions, one for the standard sprites, one for the animated sprites, and one for mixed standard/animated sprites, but I'd prefer to be able use this function as a universal collision tester so that it will still work if one or both of the objects have the .img part as an animation.
test this one, I added the width() and height() functions:
animLib daaa's mod v0.2

your "obj1.img" should be the animation so that your "obj1.img:height()" and such will work. I think it's what you want.
-= Double Post =-
Oh and you function seems to miss some cases there are cases it returns nothing. Not a problem in Lua as it will consider returning nil and nil is equivalent to false, but if sometime you want to program with another language:

Code:
function collision(obj1, obj2)
	if <cases> then
		if <cases> then
			return true
		missing else
			return false
		end
	else
		return false
	end
end
and better like this:

Code:
function collision(obj1, obj2)
	if <cases> then
		if <cases> then
			return true
		end
	end
	return false
end
__________________
Try my latest game:
MEGA DROPS 2


Last edited by daaa57150; 04-18-2007 at 12:17 AM.. Reason: Automerged Doublepost
daaa57150 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-18-2007, 12:42 AM   #7

Developer in Making...
 
BlackShark's Avatar
 
Join Date: Oct 2006
Location: Pimp'en in the US F#cking A!!!
Posts: 1,254
Trader Feedback: 0
Default

Quote:
Originally Posted by daaa17560
Hi,

Here's my 2nd lua library, in fact a mod of an existing library: animLib v4 by Grimfate126.
I changed a lot of things, and added also a lot, mainly image buffering so that animations share common image ressources.

For those who don't know animLib, this allows you to easily create animations based on multiple images or on spritesheets.

And for those who use animLib and wish to change for this mod, I'm sorry but you'll have to rewrite parts of your code because I changed a lot of things. But I think it's worth the -little- trouble.

As it's the first release and although I tested it intensively, there may be bugs or things missing or things you wouldn't expect to behave like it does... If it's the case report it there.

I'm developping a game with it and for the moment it does what I need in a great way.

I included a long readme with explanations for everything and an index.lua which will create a bunch of animations and show you how to do things.

Here is the file:
animLib daaa's mod v0.1
animLib daaa's mod v0.2 (only added width() and height() function to smoothly replace your images in your code).
Nice!, now make one in C!
__________________
The Wentire Worls in two Sectors....
When did I get dev statz?
Spoiler for my PSP homebrewReleases:
Ace of Space V1|PvP Pong Online|PvP Pong v3 | 3.03 BlackShark Custom Firmware
(PvP Pong DL'ed well over 2403 times combined! get yours now!)
Spoiler for Great Quotes:

"No Snowflake in an Avalanche ever feels responsible....." - Fortune Cookie.
BlackShark is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-18-2007, 04:43 AM   #8


Developer
 
daaa57150's Avatar
 
Join Date: Sep 2006
Location: france
Posts: 167
Trader Feedback: 0
Default

Quote:
Originally Posted by BlackShark
Nice!, now make one in C!
I'm dedicated to lua
Sorry I don't want to code in c for the PSP. But it should be easy to translate.
__________________
Try my latest game:
MEGA DROPS 2

daaa57150 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-18-2007, 02:38 PM   #9
 

 
Join Date: Feb 2007
Posts: 246
Trader Feedback: 0
Default

Hey thanks, that works great!

As for that cases thing, I just did a little test and (in lua at least) you don't need to put any "return false" statements in a function like this. It seems that unless you have a "return true" statement, it automatically returns as false.

Also, for that second example you gave, are you sure that one would work? I haven't tried it, but it seems like since you don't have the "return false" inside an if statement, it would automatically return false even if the case for "return true" was true.

I've also thought of something else that can be added - a reverse toggle. If you've got an animation of for changing the direction a sprite is facing, the way it is now you would have to create a second animation if you wanted to reverse it. Having a toggle to run the animation in reverse would save on the memory that would be needed for the second animation.
Merick is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-18-2007, 03:28 PM   #10

total-Z
 
youresam's Avatar
 
Join Date: Jul 2005
Location: texas
Posts: 2,803
Trader Feedback: 0
Default

Quote:
Originally Posted by Merick
As for that cases thing, I just did a little test and (in lua at least) you don't need to put any "return false" statements in a function like this. It seems that unless you have a "return true" statement, it automatically returns as false.
No, its not returning anything, therefore it is nil (NULL), not false, and yes there is a big difference.
__________________
牧来栠摩琠敨映汩獥
PSN: youresam
From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
youresam is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-18-2007, 03:59 PM   #11
 

 
Join Date: Feb 2007
Posts: 246
Trader Feedback: 0
Default

I see your point, but using "if collision(obj1, obj2) then code end" still works even if you don't explicitly return false from the function
Merick is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-18-2007, 09:55 PM   #12


Developer
 
daaa57150's Avatar
 
Join Date: Sep 2006
Location: france
Posts: 167
Trader Feedback: 0
Default

Quote:
Originally Posted by Merick
Also, for that second example you gave, are you sure that one would work? I haven't tried it, but it seems like since you don't have the "return false" inside an if statement, it would automatically return false even if the case for "return true" was true.
No it works, a "return" automatically stops the function, and returns its value. So in the cases it returns true, and will return false in all the other cases.

Quote:
Originally Posted by Merick
I've also thought of something else that can be added - a reverse toggle. If you've got an animation of for changing the direction a sprite is facing, the way it is now you would have to create a second animation if you wanted to reverse it. Having a toggle to run the animation in reverse would save on the memory that would be needed for the second animation.
Mmmm.... I haven't tested that sort of things yet, but I would say that reverseblit an image on the fly would be somewhat slow, therefore I would precreate all the reverse images in memory so that wouldn't save memory at all. But I can be mistaken, maybe it's not slow at all.
__________________
Try my latest game:
MEGA DROPS 2

daaa57150 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-18-2007, 09:57 PM   #13

total-Z
 
youresam's Avatar
 
Join Date: Jul 2005
Location: texas
Posts: 2,803
Trader Feedback: 0
Default

Quote:
Originally Posted by Merick
I see your point, but using "if collision(obj1, obj2) then code end" still works even if you don't explicitly return false from the function
because nil and false are the only 2 things considered false
__________________
牧来栠摩琠敨映汩獥
PSN: youresam
From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
youresam is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-19-2007, 03:20 PM   #14
 

 
Join Date: Feb 2007
Posts: 246
Trader Feedback: 0
Default

Quote:
Originally Posted by daaa57150
Mmmm.... I haven't tested that sort of things yet, but I would say that reverseblit an image on the fly would be somewhat slow, therefore I would precreate all the reverse images in memory so that wouldn't save memory at all. But I can be mistaken, maybe it's not slow at all.
I think you misunderstood me. I'm not a talking about flipping the actual images (I've already got some pretty fast functions for that thanks to cools) What I meant was a toggle which would run the frames in reverse, so that instead of drawing the frames in order 1-2-3-4 it would draw them in order 4-3-2-1. Also maybe an auto switcher to it, so that the animation would automatically change from forward to reverse when it gets to the last frame, and then switch back when it gets to the first one again.
Merick is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-19-2007, 03:35 PM   #15

Your Fate is Grim...
 
Grimfate126's Avatar
 
Join Date: Oct 2005
Posts: 2,269
Trader Feedback: 0
Default

Quote:
Originally Posted by Merick
I think you misunderstood me. I'm not a talking about flipping the actual images (I've already got some pretty fast functions for that thanks to cools) What I meant was a toggle which would run the frames in reverse, so that instead of drawing the frames in order 1-2-3-4 it would draw them in order 4-3-2-1. Also maybe an auto switcher to it, so that the animation would automatically change from forward to reverse when it gets to the last frame, and then switch back when it gets to the first one again.
its easily doable, but awfully specific. the first part is ok (reverse order of playing). but the switching should be done in your own code.
__________________
--------------------------------------------------------------------------------------
Grimfate126 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-20-2007, 12:16 AM   #16


Developer
 
daaa57150's Avatar
 
Join Date: Sep 2006
Location: france
Posts: 167
Trader Feedback: 0
Default

Quote:
Originally Posted by Merick
I think you misunderstood me. I'm not a talking about flipping the actual images (I've already got some pretty fast functions for that thanks to cools) What I meant was a toggle which would run the frames in reverse, so that instead of drawing the frames in order 1-2-3-4 it would draw them in order 4-3-2-1. Also maybe an auto switcher to it, so that the animation would automatically change from forward to reverse when it gets to the last frame, and then switch back when it gets to the first one again.
Yup, completly misunderstood . Can you PM me those flipping functions?

Quote:
Originally Posted by Grimfate126
its easily doable, but awfully specific. the first part is ok (reverse order of playing). but the switching should be done in your own code.
I think on the contrary that this would be a nice addition to the library. In fact I also would have needed this but I instead duplicated my pictures to simulate this . But it's not so trivial to do and for the moment I'm working on another library so I'll think of this later. Keep thinking on ideas Merick.




I found a bug in v0.2:
line 190 : self.loops = numloops
should be : self.loops = self.numloops

correct it until I release next version. this bug can result in a crash saying "comparing nil with number" if you try to use finishedLooping() after a blit on multiple images animations.
__________________
Try my latest game:
MEGA DROPS 2


Last edited by daaa57150; 04-20-2007 at 12:55 AM.. Reason: Automerged Doublepost
daaa57150 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-03-2007, 06:14 AM   #17


Developer
 
daaa57150's Avatar
 
Join Date: Sep 2006
Location: france
Posts: 167
Trader Feedback: 0
Default

Hey guys here's a new version, where I changed some small things and corrected others:

http://www.box.net/shared/pm42eqmsod

The changes:
Code:
added fps counter on the demo
corrected a bug in ANIM:blit()
added pixel() and save() methods so now you have all the getter methods existing on images
optimized spriteSheet animations (no more calculations on blit)
corrected a copy/paste bug in setMaxLoops() for spriteSheets
added frameChanged() method
There is a chance this is the last version I'll make because I'm tired of lua, everytime I'm doing something consistent with it (a big project) I run into random freezing. This happened to me again so I'll try c++, I don't know if I'll like that but if I manage to do what I want I'll definetely drop lua, unless a new version that does not freeze (or stops just before with a nice error message telling what's wrong) is released, which I think will never happen.

The frameChanged method tells you if the picture changed before your last blit on the animation object, useful to spare some blittings, if you want to optimize a bit.
-= Double Post =-
----


Also, if people are willing to help me, here is my current project (wanted to call it "mega puyo drop attack portable" ):
A puzzle game
It should run in any luaplayer 0.16 to 0.20 but I use it with 0.17dk (a modded version of 0.17 that allows overclocking).
If you want to help a little, just play the game and tell me how long it lasts before freezing for you.
If you are super motivated, I'd be super happy to know what's wrong, if you can find it in that mess (yeah it's not cleaned, I always do things fast and clean/improve/comment after). That is, if you believe my code is the cause, I seriously think it's the player's fault.
__________________
Try my latest game:
MEGA DROPS 2


Last edited by daaa57150; 05-03-2007 at 06:31 AM.. Reason: Automerged Doublepost
daaa57150 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-03-2007, 02:33 PM   #18
 

 
Join Date: Feb 2007
Posts: 246
Trader Feedback: 0
Default

Hmm... 35 different scripts? I've only just downloaded the game and haven't really had time to go through it yet, but a quick look through the file directories makes me think that the problem might be that you're trying to use too many dofiles

*edit*

With lua player v0.20 I get

Error: initialization.lua:93: Image.load: Error loading image.

However, in cools mod 3 I've played it for almost 30 minutes with no freezing or crashes. The problems you're having are probably because you're using an older version of the player.

Last edited by Merick; 05-03-2007 at 02:48 PM..
Merick is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-03-2007, 08:34 PM   #19

PSP Developer
 
alatnet's Avatar
 
Join Date: Oct 2005
Real First Name: Alex
Location: ~* Confidential *~
Just Played: N/A
Posts: 839
Trader Feedback: 0
Default

Interesting work.
Although, I still like my AnimatedSprite Class/Library stuff that I created.
I believe that mine might be better, but that's probably pride or something .
I am in the process of making it way better than before, but it may be a while before I release it to the public.
Also, good luck on this and ur game .
__________________

"Every team needs an idealistic person (whether they are a noob or a pro), my team doesn't have one cus im the idealistic founder."-me
Anime/Manga and Fanfiction is my inspiration!

Creator of:
- PSPSDK makefile creator - Lua Prompt - Animated Sprite Class\Library for Lua - Gmax2PSP -
alatnet is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-03-2007, 10:59 PM   #20


Developer
 
daaa57150's Avatar
 
Join Date: Sep 2006
Location: france
Posts: 167
Trader Feedback: 0
Default

Quote:
Originally Posted by Merick
Hmm... 35 different scripts? I've only just downloaded the game and haven't really had time to go through it yet, but a quick look through the file directories makes me think that the problem might be that you're trying to use too many dofiles
All dofiles are done at the beginning so all the code is directly in memory.

Quote:
Originally Posted by Merick
With lua player v0.20 I get

Error: initialization.lua:93: Image.load: Error loading image.
I don't know why you have that error.. Maybe there was a problem when you copied the images. I don't see why it wouldn't load it.
*edit* : I just tested and I got an error "cannot create image", my guess is that the memory is completely full.

Quote:
Originally Posted by Merick
However, in cools mod 3 I've played it for almost 30 minutes with no freezing or crashes. The problems you're having are probably because you're using an older version of the player.
Then I will have to test that version. I'm just afraid it will be slow as hell, I'll see.

And since you tested that thing, what do you think about it? Was that fun? You have to imagine it with some techno/electro music and sfx.
-= Double Post =-
Quote:
Originally Posted by alatnet
Interesting work.
Although, I still like my AnimatedSprite Class/Library stuff that I created.
I believe that mine might be better, but that's probably pride or something .
I am in the process of making it way better than before, but it may be a while before I release it to the public.
I looked at your AnimatedSprite lib, haven't tested but it seems it does the same so it's just a matter of preference, we each have functions the other doesn't have so it depends on the needs... Merick you may want to have a look at it, it has a reverse mode, and a collide function.
But seriously what's wrong with yours is that there is no explanation, no example, nothing. Why not write a little howto, some examples and comment your functions? Or did I miss the explanations?
Quote:
Originally Posted by alatnet
Also, good luck on this and ur game .
Thanks!
__________________
Try my latest game:
MEGA DROPS 2


Last edited by daaa57150; 05-04-2007 at 12:07 AM.. Reason: Automerged Doublepost
daaa57150 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-04-2007, 03:11 AM   #21
 

 
Join Date: Feb 2007
Posts: 246
Trader Feedback: 0
Default

It's a good beginning, but in my opinion the play area is too wide. I'm also assuming that eventually you're going to make it go faster the longer you play?
Merick is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-04-2007, 04:54 AM   #22


Developer
 
daaa57150's Avatar
 
Join Date: Sep 2006
Location: france
Posts: 167
Trader Feedback: 0
Default

Quote:
Originally Posted by Merick
It's a good beginning, but in my opinion the play area is too wide. I'm also assuming that eventually you're going to make it go faster the longer you play?
I also think the area is too wide, I wanted to get rid of 2 columns and see if that was ok. And yes I wanted to make it go faster with levels with each different bg, music, sfx, and maybe different blocks too but that's certainly too much for me. I tested a few minutes with cools mod 3 and as I expected, it is slow and I got a strange remanent effect on the blocks, nice to see but totally unexpected. Test it with 0.17dk if you want to see it with its full potential (I use the overclocking, plus 0.17 is already faster than 0.20).
__________________
Try my latest game:
MEGA DROPS 2

daaa57150 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-04-2007, 08:03 AM   #23

PSP Developer
 
alatnet's Avatar
 
Join Date: Oct 2005
Real First Name: Alex
Location: ~* Confidential *~
Just Played: N/A
Posts: 839
Trader Feedback: 0
Default

Quote:
Originally Posted by daaa57150
All dofiles are done at the beginning so all the code is directly in memory.


I don't know why you have that error.. Maybe there was a problem when you copied the images. I don't see why it wouldn't load it.
*edit* : I just tested and I got an error "cannot create image", my guess is that the memory is completely full.


Then I will have to test that version. I'm just afraid it will be slow as hell, I'll see.

And since you tested that thing, what do you think about it? Was that fun? You have to imagine it with some techno/electro music and sfx.
-= Double Post =-

I looked at your AnimatedSprite lib, haven't tested but it seems it does the same so it's just a matter of preference, we each have functions the other doesn't have so it depends on the needs... Merick you may want to have a look at it, it has a reverse mode, and a collide function.
But seriously what's wrong with yours is that there is no explanation, no example, nothing. Why not write a little howto, some examples and comment your functions? Or did I miss the explanations?

Thanks!
Um, I thought I had included a documentation file with my library...
Edit: Oops... I forgot to include the doc and example that's in v2.0...
__________________

"Every team needs an idealistic person (whether they are a noob or a pro), my team doesn't have one cus im the idealistic founder."-me
Anime/Manga and Fanfiction is my inspiration!

Creator of:
- PSPSDK makefile creator - Lua Prompt - Animated Sprite Class\Library for Lua - Gmax2PSP -
alatnet is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 03-23-2008, 01:57 AM   #24
 
Join Date: Mar 2008
Posts: 1
Trader Feedback: 0
Default little help

hey, thanks for you work, i got it to work, however, after i started adding many different animations based on player states, i keep getting this error, and I can't figure out why:


C:\Projects\game2>luaplay er script.lua
error: ./Scripts/animLibDaaa.lua:151: Image.load: Error loading image.

C:\Projects\game2>pause
Press any key to continue . . .

is there a limit to the number of frames per animation?
is there a limit to the number of animations you can have?

anyone have an idea on this?

thanks
pwhisler is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 03-23-2008, 03:11 AM   #25

...in a dream...
 
SG57's Avatar
 
Join Date: Jul 2005
Posts: 4,957
Trader Feedback: 0
Default

Quote:
Originally Posted by BlackShark
Nice!, now make one in C!
I made my own for Kitten Cannon kinda. I'll give it a shot - it'll be inspired by animlib but not the same functions, etc. (OSlib has so many great features I don't want to bottleneck it ) It'd be nice to make one for OSlib ^^ (by the way, saying "now make on in C" is ambiguous considering there's atleast a 7 different graphics libraries (someone should make a list linking to each giving descriptions and what they're meant for/good at )
__________________
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 03-25-2008, 12:40 AM   #26


Developer
 
daaa57150's Avatar
 
Join Date: Sep 2006
Location: france
Posts: 167
Trader Feedback: 0
Default

Quote:
Originally Posted by pwhisler
hey, thanks for you work, i got it to work, however, after i started adding many different animations based on player states, i keep getting this error, and I can't figure out why:


C:\Projects\game2>luaplay er script.lua
error: ./Scripts/animLibDaaa.lua:151: Image.load: Error loading image.

C:\Projects\game2>pause
Press any key to continue . . .

is there a limit to the number of frames per animation?
is there a limit to the number of animations you can have?

anyone have an idea on this?

thanks
The only thing I can think of is that you forgot to put the image on the MS and the script cannot load it.
There is no limit to the number of frames per animation nor to the number of animations you can have, the only limit is the RAM size.
Oh and the images cannot be bigger than 512x512, that's why I don't like spritesheets.
__________________
Try my latest game:
MEGA DROPS 2

daaa57150 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
animlib , lua , mod , release , v03

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 07:54 PM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us