Conception problems on activity and animation

Started by
-1 comments, last by VertPingouin 9 years, 6 months ago

Hi everyone,

I'm having trouble designing my 2d engine when it comes to displaying animation. I'm not quite sure if what I do is good in terms of object oriented conception and I need a little advice on it.

I've got thes objects :

FrameSet : a set of frames, each frames contains picture to display, hitboxes (created from white rectangles in images) and movement vector. It is created based on a xml file which is pretty self explanatory :


<frameset>
    <framenumber>5</framenumber>
    <framewidth>17</framewidth>
    <frameheight>15</frameheight>
    <mode>loop</mode>
    <picturefile>test_picture.png</picturefile>
    <hitboxes>
        <hitbox file="test_hitbox0.png" name="body" />
        <hitbox file="test_hitbox1.png" name="weapon" />
    </hitboxes>
    <frames>
	<frame number="0" duration="2" />
        <frame number="1" duration="1" />
        <frame number="2" duration="3" />
        <frame number="3" duration="4" />
        <frame number="4" duration="1" />
    </frames>
    <events>
	<kickvector frame="0" x="100" y="100" />
        <fixvector frame="0" x="20" y="20" />
    </events>
</frameset>

Animation : It has a FrameSet as attributet, it adds a clock to it and it provides proper information whenever it is called.

Activity : Instancied by gameobject when gameobject has a certain state, it applies information given by animation (self.target.picture = self.animation.getpicture(), self.target.move(self.animation.kickvector etc...)

GameObject : moving object in the game with movement vectors, statemachines and one activity. A game master clock asks it to update periodically. When it does, it updates the activity, which apply information got from animation to GameObject.

The problem with all thes objects is they're so tied together that not a single one is functional when took apart and I'm not sure this is the way to do this. Another thing is that I've got one clock per animation, but also have a master clock that would be sufficient but my game (cpuspinner with clock asking for draw and updates) never asks things directly to the animation.

Thanks for your help.

This topic is closed to new replies.

Advertisement