Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Animated texture problem

Author
Message
Laszlo
18
Years of Service
User Offline
Joined: 11th Dec 2005
Location:
Posted: 26th Jun 2006 19:01
I want to make animated texture on object plain, but I want to have all frames in one file. I think I should use scroll texture command, but all frames show on my object. Please help me!
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 26th Jun 2006 23:49 Edited at: 26th Jun 2006 23:53
You can load the file as a bitmap. Break up the bitmap into seperate images
using GET IMAGE Image Number, Left, Top, Right, Bottom, Texture Flag
in a FOR/NEXT loop. Update the texture in a loop incrementing the image
number in the TEXTURE OBJECT Object Number, Image number command.

<Edit>

Optionally, you can set the object transparency with
SET OBJECT Object Number, Wire, Transparent, Cull.
Laszlo
18
Years of Service
User Offline
Joined: 11th Dec 2005
Location:
Posted: 27th Jun 2006 15:33
Please, give me an example in code.(object have different animation when it is moving and other when it isn't moving)
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 27th Jun 2006 19:11
I can do that. I used to have a demo for doing this. I recently had to wipe my project computer due to a nasty virus. I still have to reinstall my tools and DB. Give me a day or so and I'll get back with you. The code itself won't take me long to hammer out.
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 29th Jun 2006 19:07
I finished the demo last night. I am at work right now, but when I get home, I will try an upload the zip file. The demo I wrote also has the media included. I will explain the code in my next post.
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 30th Jun 2006 00:05 Edited at: 30th Jun 2006 00:19
The demonstration program I have written is based on some of
my pervious work with 2D sprites. Although the original focus in
this thread was about animation with textures on a 3D plain,
I decided to take a 2D approach. Keep in mind that the principles
applied here will work for 3D as well. It's just a matter of
changing variable types to real numbers instead of integers for
positioning the 3D object, doing away with the sprite commands and
replacing them with 3D equivalents, and making changes to some of
the image media as well as the image indexing.

I'm assuming that you want to make a animated character from 2D
images in a 3D environment here. Even if this is not the case,
the principles still do apply for animating it...

Here are some helpful hints for doing a conversion from 2D from my example to 3D:

Creating the 3D object plain and setting object transparency:
Replace SET SPRITE 1,0,1
with MAKE OBJECT PLAIN 1,10.0:SET OBJECT 1,1,0,1

Note: The object size can be changed to suit your purposes.
The size above is for examplification.

Variable usage:

All the integer variables in the code that manipulates the object
position are now defined, calculated, and referenced as real
numbers (#) for 3D. Make sure that you make the appropriate changes
in the CASE statements in the subroutine as well.

Returning current position functions:

There are two instances that use a function that returns the
current position of the sprite in the jump portion of the
subroutine. Replace SX=SPRITE X(1) with SX#=OBJECT POSITION X(1)

Note: The calculations done for the jump will have to be
refigured to 3D spacial units instead of pixels. You will have
to experiment with the values to get the desired effect. Again
change the variables to real numbers here.

Issues with the image textures and mirroring:

Unless you make several sets of images simulating each
direction, you can't mirror a 3D object's texture in real time.
Sprites have the ability to do this with the MIRROR SPRITE command.
This makes it possible to use the same set of images to simulate
two different directions the character faces. This saves you time
and memory for the animations. For 3D you will have to get the
images from a bitmap for the first set of images and then mirror
the bitmap and repeat the process. This is the problem with using
3D objects like this. You have effectively doubled that amount of
media and memory used. That is why I chose to do this demo as 2D.
For DBPro users, 2D sprites are technically 3D.

Object travel boundries:

Again, all variables for X,Y, and Z are now real numbers. Since
the object rotates and moves according to its center axis, the 3D
units will have to be figured accordingly. The IF/THEN statements
at the end of the subroutine will have to be modified to fit your
needs.

Updating object position and texture animation:

Replace SPRITE 1,X,Y,FRAME
with POSITION OBJECT 1,X#,Y#,Z# : TEXTURE OBJECT 1,FRAME
The frames used for each action as well as the action itself
will have to be determined by you in the CASE statements.

A quick note about the character controls:

The input for controlling the characters is currently setup to
poll the keys from the keyboard. I made this part of the code
separate from the actual character action for a reason. What if
you wanted to code the inputs for a multi-key combination?
(i.e. Mortal Kombat or Street Fighter style. Up, up, down, left,
and fire button.) Maybe you want to switch the controls to a
joystick or other contol device. You could make several different
inputs depending on what you want and switch them out without
repeating the CASE statements over and over again. Although the
example doesn't show this, but You could even have two players
use different inputs to control each of their characters
(say one joystick and the other keyboard). Of course you will
require the use of arrays and/or variable types (DBPro) to keep
track each player in a loop within the subroutine. The are almost
limitless possiblities for input versus action. I think this is
probably a much cleaner approach rather than a bunch of IF/THEN
statements used to get inputs and do the action. At least I think
so anyways...

I hope this assists you in your project, Laszlo!

P.S. I had problems uploading the ZIP file. I will try again, but
I did provide the example as a snippet here just in case. The
file does have media included. Hopefully I will be able to upload
it. If not, I'll try something else.



Unfortunately I couldn't get the ZIP to upload. I will try just
sending the sprite sheets in separate posts. You will have to change
the sound files to something else or ommit them from the code.

Sorry.
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 30th Jun 2006 00:42
Here is the first sprite sheet for the demo.

Attachments

Login to view attachments
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 30th Jun 2006 00:52
This is the second sprite sheet. The sheets are big so dial up users
will have to be a little patient. I think it's worth the wait...

Attachments

Login to view attachments
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 30th Jun 2006 00:59
Here is the first wave file for jumping. I decided to give you the
sound files too!

Attachments

Login to view attachments
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 30th Jun 2006 01:00
This is the wave file I used for the sliding animation.

Attachments

Login to view attachments
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 30th Jun 2006 01:10
Oops! I forgot the extra action image. It is just a single frame that
I didn't include in the second sprite sheet for the character.

Attachments

Login to view attachments
Laszlo
18
Years of Service
User Offline
Joined: 11th Dec 2005
Location:
Posted: 3rd Jul 2006 23:51
Thank you very much
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 4th Jul 2006 18:22
No problem. I'm glad I could be of assistance.
Laszlo
18
Years of Service
User Offline
Joined: 11th Dec 2005
Location:
Posted: 12th Jul 2006 23:17 Edited at: 12th Jul 2006 23:17
I have one more question:
How to change delay between frames?
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 13th Jul 2006 00:48
There are a couple of methods you could consider for setting a delay.

The first and obvious method would be to change the frame rate. Of course
this can be a problem when you start adding other things to the game loop.
It could make the program run too slow. With the code I provided here
as is, it would be an easy remedy.

The other way would be to use timers to slow down or speed up the
animation. Just set the SYNC RATE to zero and use the timers to envoke
the frame animations at a specific interval. This way the rest of the
program will run at maximum speed.

You can maximize program execution speed with:


Add these variables into the initialization part of the code:


Replace the character action code with:

I didn't place a timer within the default case for character idle.
This demonstrates the difference in the animation speed using the
timers versus not using them. Notice that I also didn't use a timer
for single image action (case 6).

You could set different delays for each action as well. You could use
an array referencing the different times of delay for this.

Example: delay(character_action)
Laszlo
18
Years of Service
User Offline
Joined: 11th Dec 2005
Location:
Posted: 14th Jul 2006 12:27 Edited at: 14th Jul 2006 12:27
It almost works good but main object is shaking.

Look whats wrong with my code, please:

Attachments

Login to view attachments
Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 14th Jul 2006 14:55
Does DB know what Hero is?

flock
18
Years of Service
User Offline
Joined: 10th Mar 2006
Location: Earth
Posted: 14th Jul 2006 15:17
To the last post: What are you? Jordan Stories Gam...o...you are...

Yes, Jordano, DB does know what the hero var is since he already defined it!

a.k.a. "flockhound"
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 15th Jul 2006 00:16
For thorough testing purposes, I may require the media. I'll have a
look first and then I'll let you know.
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 15th Jul 2006 05:50
From the way you tried to code it, it appears that you are trying to
employ a 3rd person camera perspective on an animated texture plain.
It's actually a good idea. This would definately lower the polygon count
and the character would only need a small set of images for texturing.

In order for a 3rd person camera to work properly you must calculate
the new camera position based on the object angle. This is done with
three functions; NEWXVALUE(), NEWYVALUE(), and NEWZVALUE().

I built another demo to show how this is done properly. I've also included
the media for it (posted below this one).

Here's the new demo code:


To make the character have a frame(s) for idle,
change:


to this:


Try this one out and let me know if my asumption was correct.
Don't forget the media below.
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 15th Jul 2006 05:58
Here's the Cowboy hero!

Attachments

Login to view attachments
Laszlo
18
Years of Service
User Offline
Joined: 11th Dec 2005
Location:
Posted: 17th Jul 2006 23:57
I have given heroes2.bmp in my post. You don't need anything else to run my "game".
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 18th Jul 2006 22:39 Edited at: 18th Jul 2006 22:40
Sorry, I didn't pay any attention to the download button on your last post.

I'll have a look again...
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 18th Jul 2006 23:27
Okay, now I can see what your doing. A 3rd person top down view...
I obviously got carried away with the last demo when I didn't look at
your code carefully enough. Disreguard my last two posts unless you
can find a use for them.

To get ride of the jittering, change yor main loop to this:


The problem is that the camera doesn't get a new position until the next
loop pass. This is causing your shaking.
ZtEaLmAx
19
Years of Service
User Offline
Joined: 4th Dec 2004
Location: Sweden
Posted: 10th Oct 2006 09:41 Edited at: 10th Oct 2006 09:43
Having some small problems, cant seem to get the image transparent (The knight) a black box around him...




-------------------------------------------------------------------
Darkbasic Professionall v6.2b



Yes www.darkbasic.se - swedish forum is comming

Attachments

Login to view attachments
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 11th Oct 2006 01:57
The only thing that I can see causing your tranparency problem is the image
colorkey values may be incorrect. This is assuming that there isn't an issue
with object transparency using this method. I can't remember at the moment.
If the values are correct and it doesn't work, try changing the background
of your images to true black rgb(0,0,0) in a paint program.
ZtEaLmAx
19
Years of Service
User Offline
Joined: 4th Dec 2004
Location: Sweden
Posted: 11th Oct 2006 06:15
yea the image bg is tru black 0,0,0



Yes www.darkbasic.se - swedish forum is comming
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 11th Oct 2006 22:24 Edited at: 11th Oct 2006 22:29
If that's the case, get ride of the SET IMAGE COLORKEY command at the beginning
of code. This is telling DBPro to use (255,0,255) as the tranparency color instead of
true black (0,0,0).
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 13th Oct 2006 00:52
ZtEaLmAx, I seen your other post in the DarkBASIC Professional forum.
It's kind of frowned upon when someone cross posts like that. If you still
need help with this, I will be glad to help you here where the thread topic
had started. Of course, others here are more than welcome to help too.

Login to post a reply

Server time is: 2024-09-25 09:42:18
Your offset time is: 2024-09-25 09:42:18