Click here to Skip to main content
15,892,674 members
Articles / Multimedia / GDI+

Dungeon of Despair: A scripted demo game using Conscript

Rate me:
Please Sign up or sign in to vote.
4.96/5 (54 votes)
5 Sep 2008CPOL8 min read 92K   1.9K   103  
This article presents a demo script-driven game using Conscript, a scripting engine presented in an earlier article
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace DungeonOfDespair
{
    public class Spells
        : List<Spell>
    {
        Room m_room;

        public Spells(Room room)
        {
            m_room = room;
        }

        public void Reset()
        {
            this.Clear();
        }

        public void Update()
        {
            for (int iIndex = this.Count - 1; iIndex >= 0; iIndex--)
            {
                Spell spell = this[iIndex];
                spell.Update();
                if (!spell.Active)
                {
                    Image imageEffect = spell.Friendly
                        ? Properties.Resources.PlayerSpellBlast
                        : Properties.Resources.EnemySpellBlast;
                    Effect effect = new Effect(m_room.Effects, imageEffect, 10);
                    effect.X = spell.X;
                    effect.Y = spell.Y;
                    m_room.Effects.Add(effect);
                    this.RemoveAt(iIndex);
                }
            }
        }

        public void Draw(Graphics graphics)
        {
            foreach (Spell spell in this)
                spell.Draw(graphics);
        }

        public Room Room
        {
            get { return m_room; }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Malta Malta
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions