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.

Dark GDK / Multiple Animated Sprites, One Image

Author
Message
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 9th Apr 2008 00:58
Does anyone know if it's possible to create more than one animated sprite using the same image? Looking at the 2D template example it looks like each new sprite needs to reference a separate image even though those images are all derived from the same file. It's not that my project is necessarily wasteful of image space but it does affect the way I need to handle my OOP sprites and images.

Does anyone know if it's possible to change the affiliation of the animated sprite with an image once the animation relationship has been established? Or is there much going on in the background that makes this dangerous. My initial findings aren't good but this could be due to my lack of understanding.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 9th Apr 2008 03:07
You've already tried this I assume... its hosed?

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 9th Apr 2008 03:36
I tried to do it within the context of my OOP project. It doesn't break the program but it doesn't do what I want it to. It takes me longer to break it down into the basic GDK functionality, though I'll probably have to do that next. I was hoping that someone knew something that would let me go straight to the functionality and make it work.

My off-the-cuff guess is that the sprite number is paired with the image number and the break down by how many sub-images across and down is with the sprite not the image. I'll just have to haul out that drawing board (it's out in the garage at the moment) so I can go back to it.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 9th Apr 2008 19:24
Okay, I did some checking and it does seem that you can use the same image with more than one animated sprite. It just seems that specifying the file over again redundant. Mind you, the manner in which I I'm using this is part of my OOP and I'm creating an array of object of type Sprite. This means that each one is instantiated and then needs to be cloned. It likely means that cloning my objects nees a little work.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 10th Apr 2008 01:29
I think you'll nail this. you have pic's of your work at all? Now I'm all curious about what you're working on - justa screenie or two if you get a minute.

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 10th Apr 2008 06:26
Due to other considerations I've decided to go with texture co-ordinates. I've made some headway on this with the animated sprites but decided that I need better scrolling control.

I'm still finishing up the level design phase but I took a soire (sp?) into doing another aspect of it while inspired by some changes to my Sprite class. I'm a bit protective of the concept behind it that I don't want to go public with it. However, since you're my head cheerleader, I'd be willing to put together a brief rundown of the game and email it to you, with some pics, if you don't mind going private. It might help to get an opinion as to the viability of it.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 10th Apr 2008 13:44
Sure - BTW - I did not know about that "comma" operator you explained. Very neat - I don't understand it yet.. butI will LOL

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 10th Apr 2008 17:57
Quote: "I did not know about that "comma" operator you explained. Very neat - I don't understand it yet.. butI will LOL "


Think of it this way. It's a perfectly valid statement in C/C++ (and probably C#) to say

4 * 3;

on a line by itself. The only thing is, it doesn't do anything. It evaluates to 12 (IIRC ) and that's all it does. You may even get a warning from the compiler. In order to be of use it either needs to be evaluated as a controlling value or have a side effect such as assignment. If you string a bunch of side effects together with commas in a situation where evaluation is key and finish it off with a controlling evaluation you get multiple things done in one statement. Not that this is desirable in all cases, but some.

You can do some strange things with


while (blaha, blahb, blahc, i++ < 100);

and the same for a do/while loop. I've often done something along the lines of



even though



works as well. Mostly I use it for tightening up file input to make sure an action takes place before I test.

Another thing to keep in mind, unless they've improved the standards, is that side effect (assignments, for example) aren't guaranteed to take place at the point they appear in the code. The only requirement has been that it must take place by the end of the statement. So something like (and I'm really pulling this out of nowhere)



when the i is used in the (i - 2) expression there's no guarantee that it's value has been incremented to 7 nor can any assumption be made that it hasn't been. But it must happen by the time it reaches the ending semi-colon. The comma operator forces side effects to take place when the statement reaches the comma. That's not particularly useful in the above expression but it helps to understand what gets done when.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Ghthor
16
Years of Service
User Offline
Joined: 5th Apr 2008
Location:
Posted: 11th Apr 2008 07:38
I'm Pretty sure that you can have an unlimited amount of Sprites attached to one image. So far it hasn't bugged on me.

Taco Justice
jack leon fraust
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: unknown to me...
Posted: 22nd Apr 2008 05:48
i've gotten some extra, unwanted frames in my sprite sheet usage... has anyone else?

i also thought it would just be easier to have seperate spritesheets for, say the player,npcs,statics,environment and monsters.

as a new guy, what advice on sprites can anyone put forth?

This is not my siggie

Login to post a reply

Server time is: 2024-11-20 07:20:38
Your offset time is: 2024-11-20 07:20:38