Skip to main content
GameDev.net gamedev.net

PRO Tired of ads? Read GameDev.net ad-free and help keep the community independent with GameDev Pro — $3/month.

Animated Collections

Animated Collections

Daerax
Journal · · 2 min read
1,160 0
I have been distracted because someone on the forums mentioned Roger Zelazny's Amber Chronicles on Wednesday which meant that I had to look it up, become intrigued, buy the first 5 books and complete them yesterday.

One of my favourite series, up there with the Riftwar saga, deathgate cycle, belgariad/mallorien and farseer series. I still got 5 more books in the series to go. I see its influence on Planescape, Baldur's gate and the Game of Thrones.

Anyways I was able to integrate with the SDL animated collections. Now, Animated Sprites need not move nor must they change directions so it is silly to build in such assumptions into them. Thus I simply added two fields, another string and VisualType (static or animated) and now the set of all visual behaviour is closed. I was quite happy to see how trivial it was to extend the engine. I did not have to touch much, just add a couple of lines in two files.

I renamed what I once called objects to visual_aspect. This is because there will be two extensions to visual_aspect. Animated objects which change direction but exist only for a finite time (spells), animated objects which change direction and exist forever and can think. These will be NPCs. As well because I have decoupled actions from properties I can have arrows as Static Objects which exist for a finite time and change directions.

I am not using inheritance and instead using composition to create more complex behaviour to keep the functional way of composition as key.
-----------------
Changes:

 ActOn ( v : VisualAspect ) : Sprites.Sprite              match(v.VisualType )               | VisualType.Animated =>  def animSprite = Sprites.AnimatedSprite(Nsdl.LoadBitmapAsAnimation(v.Key , v.FurtherFlags, v.Transcolor));                                         animSprite.Animate = true;                                          animSprite ;               | VisualType.Static =>    Sprites.Sprite(Nsdl.LoadBitmap(v.Key, v.Transcolor ));                  ....            seq[ {   o.Size = bmp.Size ;                                  unless(surfacePool.Contains(o.Key))                          surfacePool = surfacePool.Add(o.Key,  bmp) } ,                                          o in TheWorld.VisualizationTree, ActOn(o) -> bmp   

 def objs = [VisualAspect(@".\Art\014.bmp", Drawing.Point(480,250), Drawing.Color.FromArgb (255,255,255), VisualType.Static() ),                          VisualAspect(@".\Art\stand2.png", Drawing.Point(920,300),Drawing.Color.FromArgb (200,140,208), VisualType.Static() ),                      VisualAspect(@".\Art\tavernx.bmp", Drawing.Point(420,260),Drawing.Color.FromArgb (200,140,208), VisualType.Static(), 2.0f )] ;                def o1 = VisualAspect(@".\Art\017.bmp",Drawing.Color.FromArgb (255,255,255), VisualType.Static() );        def ao = VisualAspect(@".\Art\Animations\BlueJet", Color.FromArgb (2, 9,124), VisualType.Animated(), 2.0f);         seq [ w.AddObject (o) , o in objs];                w.AddObject(ao);        w.AddObjectManyTimes(o1, World.RandomDistribution(95, 500));

Discussion

Loading comments...