Ejemplo n.º 1
0
        void BlitFrame(int x, int y, anim_t anim, int frame, Blitter b)
        {
            if (frame > anim.numframes)
                return;

            int frametop = anim.sizey * frame;
            b.BlitSubrect(anim.image, 0, frametop, anim.sizex, anim.sizey, x, y);
        }
Ejemplo n.º 2
0
        void BlitFrameAt(int x, int y, anim_t anim, int frame, Blitter b)
        {
            if (frame > anim.numframes)
                return;

            //if (frame == anim.bufferedframe)
            int frametop = anim.sizey * frame;
            b.BlitSubrect(anim.image, 0, frametop, anim.sizex, anim.sizey, x-anim.sizex/2, y-anim.sizey/2);
        }
Ejemplo n.º 3
0
        public override void Render(Blitter b, int x, int y, string str)
        {
            ProcessedString ps = new ProcessedString(str);

            int curCmd = ps.Commands.Count>0?0:-1;

            bool modulate = b.EnableModulate;
            b.EnableModulate = true;
            Color col = b.Color;
            b.Color = _color;
            Image wrapImage = Image.GetWrapper(textureValue);
            Vector2 textblockPosition = new Vector2(x, y);
            Vector2 vector2 = new Vector2();
            //Matrix matrix;
            //Matrix matrix2;
            //if(str == null) {
            //	throw new ArgumentNullException("text");
            //}
            //if(spriteBatch == null) {
            //	throw new ArgumentNullException("spriteBatch");
            //}
            //Matrix.CreateRotationZ(rotation, out matrix2);
            //Matrix.CreateTranslation(-origin.X * scale.X, -origin.Y * scale.Y, 0f, out matrix);
            //Matrix.Multiply(ref matrix, ref matrix2, out matrix2);
            int num2 = 1;
            float num4 = 0f;
            bool flag = true;
            //if((spriteEffects & SpriteEffects.FlipHorizontally) == SpriteEffects.FlipHorizontally) {
            //    num4 = sf.MeasureString(text).X * scale.X;
            //    num2 = -1;
            //}
            //if((spriteEffects & SpriteEffects.FlipVertically) == SpriteEffects.FlipVertically) {
            //    vector2.Y = (sf.MeasureString(text).Y - sf.LineSpacing) * scale.Y;
            //} else {
                vector2.Y = 0f;
            //}
            vector2.X = num4;
            for(int i = 0; i < ps.String.Length; i++) {
                //execute commands
                while(curCmd != -1 && curCmd < ps.Commands.Count && i == ps.Commands[curCmd].index) {
                    EmbeddedCommand cmd = ps.Commands[curCmd];
                    curCmd++;
                    if(cmd.command.StartsWith("col")) {
                        string whichColor = cmd.command.Split('=')[1];
                        if(whichColor == "def")
                            b.Color = _color;
                        else
                            b.Color = Text.Colors[whichColor];
                    }
                }
                char character = ps.String[i];
                switch(character) {
                    case '\r':
                        break;

                    case '\n':
                        flag = true;
                        vector2.X = num4;
                        //if((spriteEffects & SpriteEffects.FlipVertically) == SpriteEffects.FlipVertically) {
                        //    vector2.Y -= sf.LineSpacing * scale.Y;
                        //} else {
                        //    vector2.Y += sf.LineSpacing * scale.Y;
                        //}
                        vector2.Y += sf.LineSpacing;
                        break;

                    default: {
                            int indexForCharacter = this.GetIndexForCharacter(character);
                            Vector3 vector3 = this.kerning[indexForCharacter];
                            if(flag) {
                                vector3.X = Math.Max(vector3.X, 0f);
                            } else {
                                //vector2.X += (sf.Spacing * scale.X) * num2;
                                vector2.X += (sf.Spacing) * num2;
                            }
                            //vector2.X += (vector3.X * scale.X) * num2;
                            vector2.X += (vector3.X) * num2;
                            Rectangle rectangle = this.glyphData[indexForCharacter];
                            Rectangle rectangle2 = this.croppingData[indexForCharacter];
                            //if((spriteEffects & SpriteEffects.FlipVertically) == SpriteEffects.FlipVertically) {
                            //    rectangle2.Y = (sf.LineSpacing - rectangle.Height) - rectangle2.Y;
                            //}
                            //if((spriteEffects & SpriteEffects.FlipHorizontally) == SpriteEffects.FlipHorizontally) {
                            //    rectangle2.X -= rectangle2.Width;
                            //}
                            Vector2 position = vector2;
                            //position.X += rectangle2.X * scale.X;
                            //position.Y += rectangle2.Y * scale.Y;
                            position.X += rectangle2.X;
                            position.Y += rectangle2.Y;
                            //Vector2.Transform(ref position, ref matrix2, out position);
                            position += textblockPosition;
                            //spriteBatch.Draw(this.textureValue, position, new Rectangle?(rectangle), color, rotation, Vector2.Zero, scale, spriteEffects, depth);
                            b.BlitSubrect(wrapImage, rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height, (int)position.X, (int)position.Y);
                            flag = false;
                            //vector2.X += ((vector3.Y + vector3.Z) * scale.X) * num2;
                            vector2.X += ((vector3.Y + vector3.Z)) * num2;
                            break;
                        }
                }
            }

            b.Color = col;
            b.EnableModulate = modulate;
        }
Ejemplo n.º 4
0
 public void dice(Color tcol, Image image)
 {
     fcx = (image.Width - view.pad.Left) / (view.dims.Width + view.pad.Right);
     fcy = (image.Height - view.pad.Top) / (view.dims.Height + view.pad.Bottom);
     frames = new Image[fcy, fcx];
     for(int fy=0; fy<fcy; fy++)
         for(int fx = 0; fx < fcx; fx++) {
             int px = view.pad.Left + (view.dims.Width+view.pad.Right)*fx;
             int py = view.pad.Top + (view.dims.Height+view.pad.Bottom)*fy;
             Image img = GameEngine.Game.NewImage(view.dims.Width, view.dims.Height);
             frames[fy, fx] = img;
             Blitter b = new Blitter(img);
             b.BlitSubrect(image, px, py, img.Width, img.Height, 0, 0);
             img.Resolve();
             img.Alphafy(tcol);
         }
 }
Ejemplo n.º 5
0
        void RenderCandle(Blitter b)
        {
            if (systemtime >= spr_die)
            {
                spr_state = 0;
                return;
            }

            while (spritetimer != 0)
            {
                spritetimer--;
                ctick++;
            }
            cx = 350 - (ctick / 2);

            clangle += 16;

            int i, x, y, haloframe;
            for (i = 0; i < 4; i++)
            {
                if (systemtime > candles[i].nextframe)
                {
                    candles[i].nextframe = systemtime + Random(8, 20);
                    candles[i].frame = Random(0, 9);
                }

                x = cx + (sin(candles[i].angle + (clangle / 12)) * 30 / 65535);
                y = ybase + 100 + (sin(systemtime) * 30 / 65535) + (cos(candles[i].angle + (clangle / 12)) * 30 / 65535);
                BlitAt(x, y, candle, b);
                BlitFrameAt(x - 1, y - 14, flame, candles[i].frame, b);
                haloframe = candles[i].frame;
                if (haloframe > 4)
                    haloframe -= 5;
                BlendAdditive();
                b.BlitSubrect(halo.image, 0, halo.sizey * haloframe, halo.sizex, halo.sizey, x - 1 - (144 / 2), y - 14 - (144 / 2));
                BlendNormal();
            }
        }