示例#1
0
        public override void UpdateEntity(Entity e, GameTime gameTime, InputManager inputMan)
        {
            e.rot += e.rotvel * gameTime.ElapsedGameTime.Milliseconds;
            e.age += gameTime.ElapsedGameTime;

            e.sprite.rotation = e.rot;

            float thing = (e.vel.Y*10000f) + (float)e.age.TotalMilliseconds * e.vel.Y;
            while (thing >= 1.0f) thing -= 1.0f;
            float r = 1.0f - (3f*Math.Abs(0.3333f - thing));
            float g = 1.0f - (3f*Math.Abs(0.6667f - thing));
            float b = 1.0f - (3f*Math.Abs(1f - thing));

            if (thing < 0.3333)
            {
                g = 0;
                b = 1.0f - (thing * 3f);
            }
            else if (thing < 0.6667)
            {
                b = 0;
            }
            else if (thing < 1)
            {
                r = 0;
            }

            e.sprite.col = new Color(r, g, b) * e.vel.X;
        }
示例#2
0
        public override void UpdateEntity(Entity e, GameTime gameTime, InputManager inputMan)
        {
            e.vel.X += 0.002f * (float)(rand.NextDouble() - 0.5) * (float)(gameTime.ElapsedGameTime.Milliseconds);
            e.vel.Y += 0.002f * (float)(rand.NextDouble() - 0.5) * (float)(gameTime.ElapsedGameTime.Milliseconds);
            e.vel *= 0.1f;
            e.pos += e.vel * (float)(gameTime.ElapsedGameTime.Milliseconds) * 0.001f;
            e.age += gameTime.ElapsedGameTime;
            float halfwayPeak = (float)(e.age.TotalMilliseconds / (maxAge.TotalMilliseconds/2));
            if (halfwayPeak > 1.0f) halfwayPeak = 1.0f - (halfwayPeak - 1.0f);
            float transparency = halfwayPeak;

            e.sprite.col = new Color(255, 0, 0) * transparency;
            if (e.age > maxAge) e.dead = true;
        }
示例#3
0
        public void Update(GameTime gameTime, InputManager input)
        {
            if (speed < 0.001f)
                speed = 0;
            else
                speed *= 0.95f;
            val = 1.0f - speed;
            thing.pos.X = val - 0.5f;
            bg.col = new Color(val, val, val);

            if (gameTime.TotalGameTime.Seconds > 3)
            {
                float fadeout = 1.0f - (((float)gameTime.TotalGameTime.TotalMilliseconds - 4000f) / 2000f);
                bg.col = new Color(fadeout, fadeout, fadeout);
                thing.col = new Color(fadeout, fadeout, fadeout);
            }
            if (gameTime.TotalGameTime.Seconds > 5) active = false;
        }
示例#4
0
        public override void Update(GameTime gameTime, InputManager inputMan, WorldManager worldMan)
        {
            //title.pos.Y = 0.4f + ((float)Math.Sin(gameTime.TotalGameTime.TotalMilliseconds / 300.0) * 0.01f);

            //if (inputMan.StartPressed()) exitmenu = true;
            if (inputMan.DownPressed()) cursorpos += 1;
            if (inputMan.UpPressed()) cursorpos -= 1;
            if (cursorpos > 2) cursorpos = 0;
            if (cursorpos < 0) cursorpos = 2;

            cursor.pos.Y = 0.55f + ((float)cursorpos) * 0.05f;
            cursor.pos.X = 0.35f + ((float)Math.Sin(gameTime.TotalGameTime.TotalMilliseconds / 100.0) * 0.005f);

            el_newgame.scale = 0.5f;
            el_options.scale = 0.5f;
            el_quit.scale = 0.5f;

            if (cursorpos == 0)
            {
                el_newgame.scale = 0.6f;
                if (inputMan.EnterPressed())
                {
                    switching = true;
                    nextPage = startGamePage;
                }
            }
            else if (cursorpos == 1)
            {
                el_options.scale = 0.6f;
                if (inputMan.EnterPressed())
                {
                    //switching = true;
                }
            }
            else if (cursorpos == 2)
            {
                el_quit.scale = 0.6f;
                if (inputMan.EnterPressed())
                {
                    exit = true;
                }
            }
        }
示例#5
0
        public void Update(GameTime gameTime, InputManager inputMan, WorldManager worldMan)
        {
            if (currentMenu.SwitchingPages())
            {
                currentMenu = currentMenu.GetNextPage();
            }

            currentMenu.Update(gameTime, inputMan, worldMan);

            if (currentMenu.SaveGame())
            {
                save = true;
            }

            if (currentMenu.ExitMenu())
            {
                active = false;
            }

            if (currentMenu.ExitGame())
            {
                quit = true;
            }
        }
示例#6
0
 public virtual void UpdateEntity(Entity e, GameTime gameTime, InputManager inputMan)
 {
 }
示例#7
0
        public static void RunEditor(InputManager input)
        {
            //Debug.WriteLine("RunEditor running: " + editor_pose_loaded + " " + editor_part_selected + " " + editor_option_selected);
            if (!editor_active) return;

            //if a pose is selected, arrow key means change current selected part
            if (editor_pose_loaded && !editor_part_selected)
            {
                if (input.DownPressed())
                {
                    ++editor_current_part_index;
                    if (editor_current_part_index > selectedPose.sprites.Count - 1)
                    {
                        editor_current_part_index = 0;
                    }
                }
                if (input.UpPressed())
                {
                    --editor_current_part_index;
                    if (editor_current_part_index < 0)
                    {
                        editor_current_part_index = selectedPose.sprites.Count - 1;
                    }
                }
                selectedPart = selectedPose.sprites[editor_current_part_index];
                if (input.EnterPressed())
                {
                    editor_part_selected = true;
                }
                //if (input.BackspacePressed()) editor_pose_loaded = false;
            }
            else
            if (editor_pose_loaded && editor_part_selected && !editor_option_selected)
            {
                if (input.DownPressed())
                {
                    ++selectedOption;
                    if (selectedOption > num_part_options)
                    {
                        selectedOption = 0;
                    }
                }
                if (input.UpPressed())
                {
                    --selectedOption;
                    if (selectedOption < 0)
                    {
                        selectedOption = num_part_options;
                    }
                }
                if (input.EnterPressed())
                {
                    editor_option_selected = true;
                }
                if (input.BackspacePressed()) editor_part_selected = false;
            }
            else
            if (editor_pose_loaded && editor_part_selected && editor_option_selected)
            {
                if ((!input.IsUpPressed()) && (!input.IsDownPressed()) && (!input.IsLeftPressed()) && (!input.IsRightPressed())) editor_option_adjust_speed = 0.0f;
                else
                switch (selectedOption)
                {
                    default:
                    case 0:
                    if (input.IsLeftPressed())
                    {
                        selectedPart.x -= editor_option_adjust_speed;
                        editor_option_adjust_speed += 0.1f;
                    }
                    if (input.IsRightPressed())
                    {
                        selectedPart.x += editor_option_adjust_speed;
                        editor_option_adjust_speed += 0.1f;
                    }
                    if (input.IsDownPressed())
                    {
                        selectedPart.y += editor_option_adjust_speed;
                        editor_option_adjust_speed += 0.1f;
                    }
                    if (input.IsUpPressed())
                    {
                        selectedPart.y -= editor_option_adjust_speed;
                        editor_option_adjust_speed += 0.1f;
                    }
                    break;
                    case 1:
                    if (input.IsDownPressed() || input.IsRightPressed())
                    {
                        selectedPart.rot += editor_option_adjust_speed;
                        editor_option_adjust_speed += 0.01f;
                    }
                    if (input.IsUpPressed() || input.IsLeftPressed())
                    {
                        selectedPart.rot -= editor_option_adjust_speed;
                        editor_option_adjust_speed += 0.01f;
                    }
                    break;
                    case 2:
                    if (input.IsDownPressed() || input.IsRightPressed())
                    {
                        selectedPart.scale += editor_option_adjust_speed;
                        editor_option_adjust_speed += 0.01f;
                    }
                    if (input.IsUpPressed() || input.IsLeftPressed())
                    {
                        selectedPart.scale -= editor_option_adjust_speed;
                        editor_option_adjust_speed += 0.01f;
                    }
                    break;
                    case 3:
                    if (input.IsDownPressed() || input.IsRightPressed())
                    {
                        selectedPart.r += editor_option_adjust_speed;
                        editor_option_adjust_speed += 0.01f;
                    }
                    if (input.IsUpPressed() || input.IsLeftPressed())
                    {
                        selectedPart.r -= editor_option_adjust_speed;
                        editor_option_adjust_speed += 0.01f;
                    }
                    break;
                    case 4:
                    if (input.IsDownPressed() || input.IsRightPressed())
                    {
                        selectedPart.g += editor_option_adjust_speed;
                        editor_option_adjust_speed += 0.01f;
                    }
                    if (input.IsUpPressed() || input.IsLeftPressed())
                    {
                        selectedPart.g -= editor_option_adjust_speed;
                        editor_option_adjust_speed += 0.01f;
                    }
                    break;
                    case 5:
                    if (input.IsDownPressed() || input.IsRightPressed())
                    {
                        selectedPart.b += editor_option_adjust_speed;
                        editor_option_adjust_speed += 0.01f;
                    }
                    if (input.IsUpPressed() || input.IsLeftPressed())
                    {
                        selectedPart.b -= editor_option_adjust_speed;
                        editor_option_adjust_speed += 0.01f;
                    }
                    break;
                }
                selectedPose.sprites[editor_current_part_index] = selectedPart;
                if (input.BackspacePressed()) editor_option_selected = false;
                if (input.EnterPressed())
                {
                    for (int i = 0; i < selectedPose.sprites.Count; ++i)
                    {
                        Debug.WriteLine("anim.AddSpriteInfo(" + selectedPose.sprites[i].x
                                                         + "f," + selectedPose.sprites[i].y
                                                         + "f," + selectedPose.sprites[i].scale
                                                         + "f," + selectedPose.sprites[i].rot
                                                         + "f," + selectedPose.sprites[i].r
                                                         + "f," + selectedPose.sprites[i].g
                                                         + "f," + selectedPose.sprites[i].b
                                                         + "f);");
                    }
            //anim.AddSpriteInfo(-2f, -15f, 0.5f, 0, 0, 1f, 1f);//head
                }
            }
        }
示例#8
0
        //
        public void Update(GameTime gameTime, InputManager inputMan)
        {
            if (init)
            {
                currentLevel.Init(gameTime);
                init = false;
            }

            while (currentLevel.BlockPending())
            {
                Block addedBlock = currentLevel.GetNextBlock();
                blockMan.AddBlock(addedBlock);

                if (addedBlock.GetCollider() != null)
                    collideMan.AddBlock(addedBlock);
            }

            while (currentLevel.EntityPending())
            {
                Entity addedEnt = currentLevel.GetNextEntity();
                entMan.AddEnt(addedEnt);
            }

            currentLevel.Update(gameTime, inputMan);
            entMan.Update(gameTime, inputMan, collideMan);
            //blockMan.Update(); //currently does nothing. here for consistancy. should collideman remember level blocks for more than a frame?
            collideMan.Update(gameTime);

            if (currentLevel.LevelEnded())
            {
                LoadLevel(currentLevel.GetNextLevel());
            }
        }
示例#9
0
 public override void Update(GameTime gameTime, InputManager inputMan)
 {
     //bg.rotation += gameTime.ElapsedGameTime.Milliseconds / 3000f;
     /*
     if (gameTime.TotalGameTime - prevSpawnTime >= respawnTime)
     {
         prevSpawnTime = gameTime.TotalGameTime;
         numPendingEntities += 1;
     }*/
 }