Ejemplo n.º 1
0
 public TileMap(RenderSet render_set, int countx, int county, Texture texture)
     : base(render_set)
 {
     _CountX = countx;
     _CountY = county;
     Texture = texture;
     IndexMap = new int[_CountX,_CountY];
 }
Ejemplo n.º 2
0
        public SpriteObject(RenderSet render_set, Texture texture)
            : base(render_set, texture)
        {
            _RenderSet = render_set;

            InitPhysics();
            // HACK: Positioning the body must occur after world
            // has been solved at least one time in order to avoid
            // fixtures being shifted rather than the bodies.
            _RenderSet.Scene.Game.WorldMain.Step (0.0f);

            RenderSetEntry += EnteredRenderSet; // Virtual default event handler
        }
Ejemplo n.º 3
0
        public Dialog(RenderSet render_set, string title, List<DialogStanza> stanzas)
            : base(null)
        {
            _Title = title;
            Stanzas = stanzas;
            _RenderSet = render_set;
            _Shown = false;
            ScaleX = _RenderSet.Scene.ViewSize.X;
            ScaleY = (int)(_RenderSet.Scene.ViewSize.Y * 0.25);
            FadeUp = Texture.Get("sprite_dialog_fade_up");

            SpeakerWriter = new PTextWriter(new Size((int)ScaleX, 24));
            SpeechWriter = new PTextWriter(new Size((int)ScaleX, (int)ScaleY - 24));
        }
Ejemplo n.º 4
0
        public SpriteBase(RenderSet render_set, double x, double y, double scalex, double scaley, Texture texture)
            : base(render_set)
        {
            // Size will scale _Texture width and height
            _Color = Color.White;
            _Scale.X = scalex;
            _Scale.Y = scaley;
            _TileX = 1.0;
            _TileY = 1.0;
            _AnimationFrameIndex = 0;
            _FrameTimer = new Stopwatch();
            _AnimationDefault = _AnimationCurrent = new SpriteAnimation(texture, 0);
            //_FrameStatic = _AnimationDefault.Frames[0];

            // Position for world objects is handled differently
            if(!(this is IWorldObject))
                Corner = new Vector3d(x, y, 0.0);
        }
Ejemplo n.º 5
0
 //public VertexBuffer BPVBO { get { return _BPVBO; } }
 public SpriteFrame(Texture texture, int idx)
     : this(texture, idx, Color.White)
 {
 }
Ejemplo n.º 6
0
 public SpriteObject(RenderSet render_set, double x, double y, Texture texture)
     : this(render_set, texture)
 {
     Corner = new Vector3d(x, y, 0.0);
 }
Ejemplo n.º 7
0
 public SpriteObject(RenderSet render_set, SpriteObject relative_to, double x, double y, Texture texture)
     : this(render_set, x, y, texture)
 {
     Corner = new Vector3d(relative_to.CornerX + x, relative_to.CornerY + y, relative_to.PositionZ);;
 }
Ejemplo n.º 8
0
 public SpriteAnimation(Texture texture, int frame_time, bool looping, bool ping_pong, params int[] region_incices)
     : this(looping, ping_pong)
 {
     // TODO: make this better (supply color and frame time)
     if(region_incices == null || region_incices.Length < 1)
     {
         _Frames = new SpriteFrame[1];
         _Frames[0] = new SpriteFrame(texture, 0, Color.White, frame_time);
     }
     else
     {
         _Frames = new SpriteFrame[region_incices.Length];
         for(int i = 0; i < region_incices.Length; i++)
             _Frames[i] = new SpriteFrame(texture, region_incices[i], Color.White, frame_time);
     }
 }
Ejemplo n.º 9
0
 protected StuffOne(RenderSet render_set, double x, double y, double z, int wide, int high, Texture texture)
     : base(render_set)
 {
     _Wide = wide;
     _High = high;
     _Position.X = x;
     _Position.Y = y;
     _Position.Z = z;
     _Texture = texture;
     StuffTimer.Start();
 }
Ejemplo n.º 10
0
 public SpriteAnimation(Texture texture, int frame_time, bool looping, params string[] region_labels)
     : this(texture, frame_time, looping, false, region_labels)
 {
 }
Ejemplo n.º 11
0
 public SpriteAnimation(Texture texture, int frame_time, bool looping, bool ping_pong, params string[] region_labels)
     : this(texture, frame_time, looping, ping_pong, texture.Regions.Labeled(region_labels))
 {
 }
Ejemplo n.º 12
0
        public static Texture LoadTexture(string title, Bitmap bitmap)
        {
            int texture;

            GL.GenTextures(1, out texture);
            GL.BindTexture(TextureTarget.Texture2D, texture);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);

            BitmapData data = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height),
                                              ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, data.Width, data.Height, 0,
                          OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);

            GL.BindTexture(TextureTarget.Texture2D, 0);

            bitmap.UnlockBits(data);

            Texture T = new Texture(title, texture, bitmap.Width, bitmap.Height);
            Textures[title] = T;
            return T;
        }
Ejemplo n.º 13
0
        public static void InitialSetup()
        {
            Textures = new Hashtable();
            _DefaultTexture = LoadTexture ("sprite_null", "sprite_null.png");
            LoadTexture ("sprite_four_square", "sprite_four_square.png");
            LoadTexture ("sprite_indicator", "sprite_indicator.png");
            LoadTexture ("sprite_indicator_gloss", "sprite_indicator_gloss.png");
            LoadTexture ("sprite_spidey_0", "sprite_spidey_0.png");
            LoadTexture ("sprite_spidey_1", "sprite_spidey_1.png");

            // Scene Elements
            LoadTexture ("sprite_doorway", 			"scene_element",	"sprite_doorway.png");
            var floor_switch = LoadTexture ("sprite_floor_switch", 	"scene_element",	"sprite_floor_switch.png");
            floor_switch.Regions = new TextureRegion[4];
            floor_switch.Regions.BuildTiledRegions(4, 32, 10);
            var gateway = LoadTexture ("sprite_gateway",	 		"scene_element",	"sprite_gateway.png");
            PsdLoader.LoadSpriteSheet("sprite_mini_gate",			"scene_element",	"sprite_mini_gate.psd");
            gateway.Regions = new TextureRegion[4];
            gateway.Regions.BuildTiledRegions(4, 32, 72);

            PsdLoader.LoadSpriteSheet("sprite_projectile_switch",	"scene_element",	"sprite_projectile_switch.psd");

            var extender_platform = PsdLoader.LoadSpriteSheet("sprite_extender_platform", "scene_element", "sprite_extender_platform.psd");

            // Enemies
            var robot_1 = PsdLoader.LoadSpriteSheet("sprite_robot_1", "baddie", "sprite_robot_1.psd");

            // Props
            LoadTexture ("sprite_metal_ball",		    "prop",				"sprite_metal_ball.png");
            PsdLoader.LoadSpriteSheet ("sprite_radio",  "prop",             "sprite_radio.psd");

            // Projectiles
            LoadTexture ("sprite_first_bullet", 	"projectile",		"sprite_first_bullet.png");
            PsdLoader.LoadSpriteSheet("sprite_bullet_collision_particle",   "projectile",   "sprite_bullet_collision_particle.psd");

            var bunker_floor = LoadTexture("sprite_bunker_floor",		"scene_element",   "sprite_bunker_floor.png");
            bunker_floor.Regions = new TextureRegion[4];
            bunker_floor.Regions.BuildTiledRegions(4, 32, 32);

            var floor = LoadTexture("sprite_tile_floor_atlas",		"background",   "sprite_tile_floor_atlas.png");
            floor.Regions = new TextureRegion[3];
            floor.Regions.BuildTiledRegions(4, 32, 32);

            var bunker_floor_2 = LoadTexture("sprite_bunker_floor_2",		"scene_element",   "sprite_bunker_floor_2.png");
            bunker_floor_2.Regions = new TextureRegion[4];
            bunker_floor_2.Regions.BuildTiledRegions(4, 32, 104);

            var bunker_wall = LoadTexture("sprite_bunker_wall",		"scene_element",   "sprite_bunker_wall.png");
            bunker_wall.Regions = new TextureRegion[4];
            bunker_wall.Regions.BuildTiledRegions(1, 16, 32);

            // Character
            PsdLoader.LoadSpriteSheet ("sprite_player", "character",	"sprite_protagonist.psd");
            LoadTexture("sprite_protagonist_picture", 	"character",	"sprite_protagonist_picture.png");
            LoadTexture ("sprite_radio_picture",        "character",    "sprite_radio_picture.png");

            // Dialog box
            LoadTexture ("sprite_dialog_fade_up",	"dialog_box",	"sprite_dialog_fade_up.png");

            // User interface
            var health_meter = LoadTexture ("sprite_health_meter_atlas",	"user_interface",	"sprite_health_meter_atlas.png");
            health_meter.Regions = new TextureRegion[18];
            health_meter.Regions.BuildTiledRegions(6, 32, 32);

            var main_menu_buttons = LoadTexture ("sprite_main_menu_buttons",	"user_interface", "sprite_main_menu_buttons.png");
            main_menu_buttons.Regions = new TextureRegion[6];
            main_menu_buttons.Regions.BuildTiledRegions(2, 128, 32);

            var android_now = PsdLoader.LoadSpriteSheet("sprite_android_now", "sprite_android_now.psd");

            // Background
            // TODO: make this not-hardcoded
            var bg = LoadTexture("sprite_tile_bg_atlas",		"background",   "sprite_tile_bg_atlas.png");
            bg.Regions = new TextureRegion[32];
            bg.Regions.BuildTiledRegions(4, 32, 32);

            var bg2 = LoadTexture("sprite_tile_bg2_atlas",		"background",   "sprite_tile_bg2_atlas.png");
            bg2.Regions = new TextureRegion[32];
            bg2.Regions.BuildTiledRegions(4, 32, 32);

            var bg3 = LoadTexture("sprite_tile_bg3_atlas",		"background",   "sprite_tile_bg3_atlas.png");
            bg3.Regions = new TextureRegion[32];
            bg3.Regions.BuildTiledRegions(4, 32, 32);

            var bg4 = LoadTexture("sprite_tile_bg4_atlas",      "background",   "sprite_tile_bg4_atlas.png");
            bg4.Regions = new TextureRegion[64];
            bg4.Regions.BuildTiledRegions(8, 32, 32);

            var bg_rubble = LoadTexture("sprite_dark_rubble_atlas",		"background",   "sprite_dark_rubble_atlas.png");
            bg_rubble.Regions = new TextureRegion[32];
            bg_rubble.Regions.BuildTiledRegions(4, 32, 32);

            var bg_pipes = LoadTexture("sprite_bg_pipes", "background", "sprite_bg_pipes.png");

            var infogfx_cabinet = PsdLoader.LoadSpriteSheet("sprite_infogfx_cabinet_buttons", "user_interface", "sprite_infogfx_cabinet_buttons.psd");

            // TEST PSDLOADER
            PsdLoader.LoadSpriteSheet("sprite_dumbo", "sprite_dumbo.psd");
        }
Ejemplo n.º 14
0
 public SpriteBase(RenderSet render_set, Texture texture)
     : this(render_set, 0.0, 0.0, 1.0, 1.0, texture)
 {
 }
Ejemplo n.º 15
0
 public Player(RenderSet render_set, Texture texture)
     : this(render_set, 0.0, 0.0, texture)
 {
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="positron.SpriteBase+SpriteAnimation"/> class.
 /// If region_indices is empty, frame_time instead defines first frame and default frame time is used,
 /// otherwise frame time is the first integer parameter followed by texture region indices for frames.
 /// </summary>
 public SpriteAnimation(Texture texture, int frame_time, params int[] region_incices)
     : this(texture,
     region_incices != null && region_incices.Length > 0 ? frame_time : _FrameTimeDefault,
     false, false,
     region_incices != null && region_incices.Length > 0 ? region_incices : new int[1] { frame_time })
 {
 }
Ejemplo n.º 17
0
 public SpriteAnimation(Texture texture, bool looping, params int[] region_incices)
     : this(texture, looping, false, region_incices)
 {
 }
Ejemplo n.º 18
0
 public SpriteAnimation(Texture texture, bool looping, bool ping_pong, params int[] region_incices)
     : this(texture, _FrameTimeDefault, looping, ping_pong, region_incices)
 {
 }
Ejemplo n.º 19
0
 public SpriteAnimation(Texture texture, params string[] region_labels)
     : this(texture, false, region_labels)
 {
 }
Ejemplo n.º 20
0
 //            public SpriteAnimation(Texture texture, int frame_time, params string[] region_labels) :
 //                this(texture, frame_time, false, region_labels)
 //            {
 //            }
 public SpriteAnimation(Texture texture, bool looping, bool ping_pong, params string[] region_labels)
     : this(texture, _FrameTimeDefault, looping, ping_pong, region_labels)
 {
 }
Ejemplo n.º 21
0
        // Main constructor:
        public Player(RenderSet render_set, double x, double y, Texture texture)
            : base(render_set, x, y, texture)
        {
            HealthChanged += (object sender, HealthChangedEventArgs e) => { _Health = Math.Max (0, e.HealthNow); };
            OnHealthChanged(this, _HealthMax);

            AnimationStand = 	new SpriteAnimation(texture, "protag standing");
            AnimationWalk  = 		new SpriteAnimation(texture, true, "protag walking 1", "protag walking 2", "protag walking 3", "protag walking 4");
            AnimationStationaryFw = new SpriteAnimation(texture, "protag standing facing front");
            AnimationWalkFw = 		new SpriteAnimation(texture, true, "protag walking front 1", "protag walking front 2", "protag walking front 3", "protag walking front 4");
            AnimationStationaryBk = new SpriteAnimation(texture, "protag standing back" );
            AnimationWalkBk = 		new SpriteAnimation(texture, true, "protag walking back 1", "protag walking back 2", "protag walking back 3", "protag walking back 4");

            AnimationCrouch =		new SpriteAnimation(texture, true, "protag crouch");
            AnimationCrawl =		new SpriteAnimation(texture, 150, true, "protag crouch walk 1", "protag crouch walk 2", "protag crouch walk 3", "protag crouch walk 4");

            AnimationPreJump = 		new SpriteAnimation(texture, "protag jumping 2");
            AnimationJumping = 		new SpriteAnimation(texture, "protag jumping 2");
            AnimationEndJump = 		new SpriteAnimation(texture, "protag jumping 4");

            AnimationAimGunFwd = 		new SpriteAnimation(texture, true, "protag aiming gun");
            AnimationAimGunFwdUp = 		new SpriteAnimation(texture, true, "protag aiming gun up");
            AnimationAimGunFwdDown = 	new SpriteAnimation(texture, true, "protag aiming gun down");
            AnimationAimGunFwdCrouch = 	new SpriteAnimation(texture, true, "protag aiming gun crouch");
            AnimationAimGunFwdJump = 	new SpriteAnimation(texture, true, "protag aiming gun jump");

            AnimationPreJump.Frames[0].FrameTime = 100;
            //AnimationPreJump.Frames[1].FrameTime = 50;

            AnimationEndJump.Frames[0].FrameTime = 200;

            _FrameTimer.Start ();
            JumpTimer.Start();
        }
Ejemplo n.º 22
0
 public SpriteFrame(Texture texture, int idx, Color color)
     : this(texture, idx, color, 100)
 {
 }
Ejemplo n.º 23
0
 public static void Bind(Texture t)
 {
     GL.BindTexture(TextureTarget.Texture2D, t.TextureID);
 }
Ejemplo n.º 24
0
 public SpriteFrame(Texture texture, int idx, Color color, int frame_time)
 {
     _Texture = texture;
     _TextureRegionIndex = idx;
     _Color = color;
     _FrameTime = frame_time;
     _TileX = 1.0;
     _TileY = 1.0;
     Build();
 }
Ejemplo n.º 25
0
 public DialogSpeaker(string name, Texture picture)
 {
     Name = name;
     Picture = picture;
 }
Ejemplo n.º 26
0
 // Main constructor:
 public SpriteBase(RenderSet render_set, double x, double y, Texture texture)
     : this(render_set, x, y, 1.0, 1.0, texture)
 {
 }
Ejemplo n.º 27
0
 public FadedTileMap(RenderSet render_set, int countx, int county, Texture texture)
     : base(render_set, countx, county, texture)
 {
 }
Ejemplo n.º 28
0
 public virtual void Dispose()
 {
     if (_VBO != null) {
         _VBO.Dispose ();
         _VBO = null;
     }
     _Texture = null;
 }
Ejemplo n.º 29
0
 protected BunkerFloor(Scene scene, double x, double y, Texture texture)
     : base(scene.Stage, x, y, texture)
 {
     _Variant = Variance.Next(Texture.Regions.Length);
     PlayAnimation(_AnimationDefault = new SpriteAnimation(Texture, _Variant));
 }
Ejemplo n.º 30
0
        public static void SlicesToTextureRegionInfo(this PsdFile psd, ref Texture texture)
        {
            RawImageResource slices_resource = (RawImageResource)psd.ImageResources.Find (resource => resource.ID == ResourceID.Slices);

            //			Console.Write("Slices image resource:"); // Newline handled by ternary
            //			for(int i = 0; i < slices_resource.Data.Length; i++)
            //			{
            //				char c = MathUtil.Clamp((char)slices_resource.Data[i], '~', ' ');
            //				if(c == slices_resource.Data[i])
            //					Console.Write(c);
            //				else
            //					Console.Write("[{0}]", slices_resource.Data[i]);
            //			}

            PsdSlicesHeader psd_slices_header = new PsdSlicesHeader ();
            PsdSlice[] psd_slices;
            // FixedEndianness and ReadPascalString are defined in Utility.Structure
            using (BinaryReader reader = new BinaryReader(new MemoryStream(slices_resource.Data), Encoding.BigEndianUnicode)) {
                psd_slices_header.Version = reader.ReadInt32 ().FixEndianness ();
                psd_slices_header.Top = reader.ReadInt32 ().FixEndianness ();
                psd_slices_header.Left = reader.ReadInt32 ().FixEndianness ();
                psd_slices_header.Bottom = reader.ReadInt32 ().FixEndianness ();
                psd_slices_header.Right = reader.ReadInt32 ().FixEndianness ();
                psd_slices_header.GroupName = reader.ReadPascalString ();
                psd_slices_header.SliceCount = reader.ReadInt32 ().FixEndianness ();

                int len = psd_slices_header.SliceCount;
                psd_slices = new PsdSlice[len];

                // This is terrifying
                for (int i = 0; i < len; i++) {
                    psd_slices [i] = new PsdSlice ();
                    psd_slices [i].Id = reader.ReadInt32 ().FixEndianness ();
                    psd_slices [i].GroupId = reader.ReadInt32 ().FixEndianness ();
                    psd_slices [i].Origin = reader.ReadInt32 ().FixEndianness ();
                    if (psd_slices [i].Origin == 1)
                        psd_slices [i].AssociatedLayerId = reader.ReadInt32 ().FixEndianness ();
                    psd_slices [i].Name = reader.ReadPascalString ();
                    psd_slices [i].Type = reader.ReadInt32 ().FixEndianness ();
                    psd_slices [i].Left = reader.ReadInt32 ().FixEndianness ();
                    psd_slices [i].Top = reader.ReadInt32 ().FixEndianness ();
                    psd_slices [i].Right = reader.ReadInt32 ().FixEndianness ();
                    psd_slices [i].Bottom = reader.ReadInt32 ().FixEndianness ();
                    psd_slices [i].URL = reader.ReadPascalString ();
                    psd_slices [i].Target = reader.ReadPascalString ();
                    psd_slices [i].Message = reader.ReadPascalString ();
                    psd_slices [i].AltTag = reader.ReadPascalString ();
                    psd_slices [i].CellIsHTML = reader.ReadBoolean ();
                    psd_slices [i].CellText = reader.ReadPascalString ();
                    psd_slices [i].HorizontalAlignment = reader.ReadInt32 ().FixEndianness ();
                    psd_slices [i].VerticalAlignment = reader.ReadInt32 ().FixEndianness ();
                    psd_slices [i].A = reader.ReadByte ();
                    psd_slices [i].R = reader.ReadByte ();
                    psd_slices [i].G = reader.ReadByte ();
                    psd_slices [i].B = reader.ReadByte ();
                }
            }

            var tr = new List<TextureRegion> ();
            var set_corner = new List<TextureRegion> ();
            for (int i = 0; i < psd_slices.Length; i++) {
                PsdSlice slice = psd_slices [i];
                if (slice.Name != "") {
                    TextureRegion region =
                        new TextureRegion (slice.Name,
                                          new Vector2d (slice.Left, psd.RowCount - slice.Bottom),
                                          new Vector2d (slice.Right, psd.RowCount - slice.Top)); // Vertical axis (Y) is flipped

                    if (slice.Target.ToLower () == "default")
                        texture.DefaultRegionIndex = tr.Count;
                    if (slice.Target.ToLower () == "corner") {
                        set_corner.Add (region);
                    }
                    tr.Add (region);
                }
            }

            texture.Regions = tr.ToArray();

            // Set the origin of these regions to a position that aligns its
            // lower left corner with the default region
            for (int i = 0; i < set_corner.Count; i++) {
                Vector2d origin_offset = 0.5 * (set_corner[i].Size - texture.DefaultRegion.Size);
                //Console.WriteLine("Expected: {0}", origin);
                set_corner[i].OriginOffset = origin_offset;
                //Console.WriteLine("Result: {0}", set_corner[i].OriginOffset);
            }
        }