Easy GL2D

User projects written in or related to FreeBASIC.
super_castle
Posts: 289
Joined: Oct 10, 2006 7:19

Postby super_castle » Sep 10, 2010 14:47

you can do something like that?
a caterpillar where the two poor can be rotated independently?

gruss
relsoft
Posts: 1767
Joined: May 27, 2005 10:34
Location: Philippines
Contact:

Postby relsoft » Sep 10, 2010 15:07

Yes.
fernando.inf
Posts: 28
Joined: Mar 10, 2009 1:41
Contact:

Postby fernando.inf » Sep 10, 2010 18:02

hello relsoft!

I was impressed with the speed and ease of use the engine.

One question, it would be possible to run several animations at the same time with different FPS speed?
super_castle
Posts: 289
Joined: Oct 10, 2006 7:19

Postby super_castle » Sep 11, 2010 7:28

you can create an example with caterpillar ?

gruss
relsoft
Posts: 1767
Joined: May 27, 2005 10:34
Location: Philippines
Contact:

Postby relsoft » Sep 11, 2010 7:38

fernando.inf: What does different FPS mean? If you are asking whether you could animate sprites with different speeds, then yes you can. Also if you want to use a frame independent timing(ie. delta_time), it's not hard to implement either.

super_castle: I'm not at home but I'll ask my sister if shed allow e to install FB here. BTW, do you want the standard or the fb.image compatible lib?

15 minute job:

http://www.file-pasta.com/file/0/cateplillar.rar

Tip: to make the segment distances equal, you could use a distance parametized catmull-rom to trace the segments. But that would involve an sqr() so....
fernando.inf
Posts: 28
Joined: Mar 10, 2009 1:41
Contact:

Postby fernando.inf » Sep 11, 2010 15:45

Yes, animated with different speeds.

I'm currently using allegro, but I was thinking about testing your GL2D because I was impressed with him.


Sorry for bad english :(
relsoft
Posts: 1767
Joined: May 27, 2005 10:34
Location: Philippines
Contact:

Postby relsoft » Sep 12, 2010 0:24

Definitely. Easy GL2D is just a rendering engine. All you have to do is to port the allegro specific stuff and it would compile fine.
fernando.inf
Posts: 28
Joined: Mar 10, 2009 1:41
Contact:

Postby fernando.inf » Sep 12, 2010 2:15

Yes, I thought about doing this because I really liked gl2d.

you could make an example of animation with different speeds with GL2D?

would be very grateful.
rolliebollocks
Posts: 2655
Joined: Aug 28, 2008 10:54
Location: new york

Postby rolliebollocks » Sep 12, 2010 2:31

My animation engine can animate sprites at different speeds, I'm in the process of porting it to fbgl.

You need a separate anaimation class which is out of scope for rel's library probably. You're asking him to write your code for you. You can find an implementation of a timer delay animation here:

http://www.freebasic.net/forum/viewtopic.php?t=16297
fernando.inf
Posts: 28
Joined: Mar 10, 2009 1:41
Contact:

Postby fernando.inf » Sep 12, 2010 4:37

rolliebollocks you are right.
I just asked, why have it in allegro, and I believe it is not difficult to implement in GL2D anyway I will look at your engine animation and studied best in GL2D.

Thanks for the replies, and sorry for the bad habit of asking before studying.
relsoft
Posts: 1767
Joined: May 27, 2005 10:34
Location: Philippines
Contact:

Postby relsoft » Sep 12, 2010 5:02

fernando.inf wrote:rolliebollocks you are right.
I just asked, why have it in allegro, and I believe it is not difficult to implement in GL2D anyway I will look at your engine animation and studied best in GL2D.

Thanks for the replies, and sorry for the bad habit of asking before studying.


How do you set up those animation parameters in allegro? I haven't used it ever so I can't really speculate.
fernando.inf
Posts: 28
Joined: Mar 10, 2009 1:41
Contact:

Postby fernando.inf » Sep 12, 2010 6:53

Hello relsoft!

I created an object called animation, and instantiate it as follows:

Code: Select all

Dim As Animation Ptr myAnim = New Animation
Dim as Animation Ptr mainFPS = New Animation

mainFPS->initFPS(60)
myAnim->init(filename, x, y, fps, frameStart, frameEnd, currentFrame, isLoop, isReverse)


use as follows:

Code: Select all

''  Main loop
do
    myAnim->update()
    'myAnim1->update()
    'myAnim2->update()
    'etc....

    mainFPS->loopControl()
loop until exit_app  = True
delete myAnim


Explanation:

FPS control is done with a timer in the allegro.
mainFPS is the object that calculates the FPS and updates the screen.

The technique I used was: do not lock the fps, but just do render to buffer after reaching the right time for each animation.

Then I have many animations at different speeds because they will only draw into the buffer when it reaches the correct FPS of each, and the update screen is the same way, each 60fps it updates the buffer to the screen.

I do not know if you understand because of my bad English?
relsoft
Posts: 1767
Joined: May 27, 2005 10:34
Location: Philippines
Contact:

Postby relsoft » Sep 12, 2010 6:59

I'm assuming you are loading each sprite as a separate image? Or do you use a spriteset?

BTW, I need to see your working demo's source if it's okay. You can email it to me if you want.

This:

Code: Select all

myAnim->init(filename, x, y, fps, frameStart, frameEnd, currentFrame, isLoop, isReverse)


Would really be easy to wrap with the init_sprite() routine since it uses indices (so frameend and framestart are useable)

[edit]

Are you using a fixed timestep or deltatiming?
fernando.inf
Posts: 28
Joined: Mar 10, 2009 1:41
Contact:

Postby fernando.inf » Sep 13, 2010 3:50

relsoft hello again!

I use all images in a datafile of the allegro.

I'm using each sprite as a separate image, but I also have an init routine in the animation object which supports several sprites in a single image, where two parameters inform the most telling how many sprites the image has vertical and many horizontal (row and spine) remembering that in my case the sprites must have the same size as the routine calculates the size of each one and make the cut according to the amount reported

I could not use all the images in a single spriteset like you, because I use screen resolution is 1024x768 and has about 10 background images with this size, and several other large images, taking the total over 500 PNG images, I believe that would sriteset giant.

About the sources, I could not send the entire code, because currently has 52 separate files in 14 folders, with over 15 000 lines of code, use allegro, libpng, loadpng, libmysql, etc.. And I'm developing this for others, then it would be unethical of my part.

But I can separate the animations and FPS control, create a demo with some animations running at different speeds and post here or send it to you, how you want.

I do not understand the deltatiming, but do so: Calculate the time that each frame should last according to the desired FPS in animation, calculate how long it took, and I see it did not exceed the duration of each frame, I went off this time next frame, and also calculate the lost frames if any.

Well, actually I'm newbie in this, I begin to use FreeBASIC a short time, whenever I enter the forum to find and track new things, but do not put many posts due to my English very bad.

I'll look at backups if I no longer have the animated part of the separate sources and sending it.

Thanks for the reply, and I use to tell everyone that I have learned a lot from the community, with examples and good will of the participants.
relsoft
Posts: 1767
Joined: May 27, 2005 10:34
Location: Philippines
Contact:

Postby relsoft » Sep 13, 2010 6:10

Don't bother sending me the source. I think I got the idea. I may be able to make a simple demo later.

Are those BGs gonna reside in memory all the time?

Return to “Projects”

Who is online

Users browsing this forum: srvaldez and 14 guests