public static List<AnimationParticle> Particles = new List<AnimationParticle>(); //todo: move animations to their own file. Let generators chain into other generators for complex and repeating effects.

        #endregion Fields

        #region Methods

        public static void DoStuffTodoRename(int num_per_frame_todo,int duration_todo,int num_frames_todo)
        {
            GLGame.particle_surface.Disabled = false;
            List<AnimationParticle> l = new List<AnimationParticle>();
            float player_row = (float)Actor.player.row - 0.325f;
            float player_col;
            {
                int graphics_mode_first_col = Screen.screen_center_col - 16;
                int graphics_mode_last_col = Screen.screen_center_col + 16;
                if(graphics_mode_first_col < 0){
                    graphics_mode_last_col -= graphics_mode_first_col;
                    graphics_mode_first_col = 0;
                }
                else{
                    if(graphics_mode_last_col >= Global.COLS){
                        int diff = graphics_mode_last_col - (Global.COLS-1);
                        graphics_mode_first_col -= diff;
                        graphics_mode_last_col = Global.COLS-1;
                    }
                }
                player_col = (float)(Actor.player.col - graphics_mode_first_col) + 0.4375f;
            }
            float dx = 0.1f;
            float dy = 0.1f;
            for(int time=0;time<num_frames_todo + duration_todo - 1;++time){
                for(int num=0;num<num_per_frame_todo;++num){
                    l.Add(new AnimationParticle(time+duration_todo,player_row + (float)(R.Between(-100,100)) / 10,player_col + (float)(R.Between(-100,100)) / 10,0,0,5,3,Color4.Magenta,Color4.Yellow));
                    //l.Add(new AnimationParticle(time+duration_todo,player_col,player_row,0,0,5,3,Color4.DarkRed,Color4.Cyan)); //todo
                }
                l.RemoveWhere(p => time >= p.frames_left);
                foreach(AnimationParticle p in l){
                    p.col += dx;
                    p.row += dy;
                }
                Game.gl.UpdateParticles(GLGame.particle_surface,l);
                Game.gl.Render(); //todo: update or render?
                Thread.Sleep(20);
            }
            GLGame.particle_surface.Disabled = true;
            GLGame.particle_surface.NumElements = 0;
        }
Example #2
0
 public void SmoothCorners(int percent_chance)
 {
     List<pos> corners = new List<pos>();
     for(int i=1;i<H-1;++i){
         for(int j=1;j<W-1;++j){
             if(IsCornerFloor(i,j)){
                 corners.Add(new pos(i,j));
             }
         }
     }
     while(corners.Count > 0){
         pos p = corners.RemoveRandom();
         corners.RemoveWhere(x=>x.DistanceFrom(p) <= 1);
         if(R.PercentChance(percent_chance)){
             map[p] = CellType.Wall;
         }
     }
 }