示例#1
0
        public void Initialize()
        {
            v_window = new Spartacus.Forms.Window("Spartacus Pong", 800, 600);

            v_racket_left = new Spartacus.Game.Object("RL", 20, (v_window.v_height - 100) / 2, 20, 100);
            v_racket_left.AddImage("racket.png");

            v_racket_right = new Spartacus.Game.Object("RR", v_window.v_width - 40, (v_window.v_height - 100) / 2, 20, 100);
            v_racket_right.AddImage("racket.png");

            v_ball = new Spartacus.Game.Object("B", v_window.v_width / 2, v_window.v_height / 2, 15, 15);
            v_ball.AddImage("ball.png");
            v_ball_x = 10;
            v_ball_y = 10;

            v_bound_up    = new Spartacus.Game.Object("BU", 0, 0, v_window.v_width, 10);
            v_bound_down  = new Spartacus.Game.Object("BD", 0, v_window.v_height - 10, v_window.v_width, 10);
            v_bound_left  = new Spartacus.Game.Object("BL", 0, 0, 10, v_window.v_height);
            v_bound_right = new Spartacus.Game.Object("BR", v_window.v_width - 10, 0, 10, v_window.v_height);

            v_score_left = new Spartacus.Game.Text(80, 10, "Courier New", 14, 255, 255, 255, 255);
            v_score_left.SetMessage("0");

            v_score_right = new Spartacus.Game.Text(v_window.v_width - 100, 10, "Courier New", 14, 255, 255, 255, 255);
            v_score_right.SetMessage("0");

            v_text_paused = new Spartacus.Game.Text((v_window.v_width - 50) / 2, 10, "Courier New", 14, 255, 255, 255, 255);
            v_text_paused.SetMessage("");
            v_paused = false;

            v_layer = new Spartacus.Game.Layer();
            v_layer.AddObject(v_racket_left);
            v_layer.AddObject(v_racket_right);
            v_layer.AddObject(v_ball);
            v_layer.AddObject(v_bound_up);
            v_layer.AddObject(v_bound_down);
            v_layer.AddObject(v_bound_left);
            v_layer.AddObject(v_bound_right);
            v_layer.AddText(v_score_left);
            v_layer.AddText(v_score_right);
            v_layer.AddText(v_text_paused);
            v_layer.Collision += this.OnCollision;

            v_keyboard           = new Spartacus.Game.Keyboard(v_window);
            v_keyboard.KeyDown  += this.OnKeyDown;
            v_keyboard.KeyPress += this.OnKeyPress;
            v_keyboard.Start(60);

            v_level = new Spartacus.Game.Level(v_window);
            v_level.AddLayer(v_layer);
            v_level.Time += this.OnTime;
            v_level.Start(30);

            v_window.Run();
        }
示例#2
0
        private void BuidGuiView()
        {
            Spartacus.Game.Object v_object;
            Spartacus.Game.Text   v_text;

            // 0 - Soldier Name
            v_text = new Spartacus.Game.Text(700, 100, "Courier New", 16, 255, 255, 255, 255);
            //v_text.SetMessage("Soldier 1");
            this.v_guiview.AddText(v_text);

            // 1 - Soldier Health
            v_text = new Spartacus.Game.Text(880, 155, "Courier New", 12, 255, 255, 255, 255);
            //v_text.SetMessage("100/100");
            this.v_guiview.AddText(v_text);

            // 2 - Soldier Actions
            v_text = new Spartacus.Game.Text(920, 205, "Courier New", 12, 255, 255, 255, 255);
            //v_text.SetMessage("3/3");
            this.v_guiview.AddText(v_text);

            // 3 - Soldier Stamina
            v_text = new Spartacus.Game.Text(880, 355, "Courier New", 12, 255, 255, 255, 255);
            //v_text.SetMessage("100/100");
            this.v_guiview.AddText(v_text);

            // 4 - Soldier Ammo
            v_text = new Spartacus.Game.Text(900, 405, "Courier New", 12, 255, 255, 255, 255);
            //v_text.SetMessage("20/20");
            this.v_guiview.AddText(v_text);

            // 5 - Soldier Grenades
            v_text = new Spartacus.Game.Text(920, 455, "Courier New", 12, 255, 255, 255, 255);
            //v_text.SetMessage("2/2");
            this.v_guiview.AddText(v_text);

            v_object = new Spartacus.Game.Object("health", 700, 150, 32, 32);
            v_object.AddImage("gui/health.png");
            this.v_guiview.AddObject(v_object);

            v_text = new Spartacus.Game.Text(750, 155, "Courier New", 12, 255, 255, 255, 255);
            v_text.SetMessage("Health");
            this.v_guiview.AddText(v_text);

            v_object = new Spartacus.Game.Object("actions", 700, 200, 32, 32);
            v_object.AddImage("gui/actions.png");
            this.v_guiview.AddObject(v_object);

            v_text = new Spartacus.Game.Text(750, 205, "Courier New", 12, 255, 255, 255, 255);
            v_text.SetMessage("Actions");
            this.v_guiview.AddText(v_text);

            v_object = new Spartacus.Game.Object("stop", 700, 250, 32, 32);
            v_object.AddImage("gui/stop.png");
            v_object.AddImage("gui/stop_" + this.v_player + ".png");
            this.v_guiview.AddObject(v_object);

            v_text = new Spartacus.Game.Text(750, 255, "Courier New", 12, 255, 255, 255, 255);
            v_text.SetMessage("Stop");
            this.v_guiview.AddText(v_text);

            v_object = new Spartacus.Game.Object("walk", 700, 300, 32, 32);
            v_object.AddImage("gui/walk.png");
            v_object.AddImage("gui/walk_" + this.v_player + ".png");
            this.v_guiview.AddObject(v_object);

            v_text = new Spartacus.Game.Text(750, 305, "Courier New", 12, 255, 255, 255, 255);
            v_text.SetMessage("Walk");
            this.v_guiview.AddText(v_text);

            v_object = new Spartacus.Game.Object("run", 700, 350, 32, 32);
            v_object.AddImage("gui/run.png");
            v_object.AddImage("gui/run_" + this.v_player + ".png");
            this.v_guiview.AddObject(v_object);

            v_text = new Spartacus.Game.Text(750, 355, "Courier New", 12, 255, 255, 255, 255);
            v_text.SetMessage("Run");
            this.v_guiview.AddText(v_text);

            v_object = new Spartacus.Game.Object("shoot", 700, 400, 32, 32);
            v_object.AddImage("gui/shoot.png");
            v_object.AddImage("gui/shoot_" + this.v_player + ".png");
            this.v_guiview.AddObject(v_object);

            v_text = new Spartacus.Game.Text(750, 405, "Courier New", 12, 255, 255, 255, 255);
            v_text.SetMessage("Shoot");
            this.v_guiview.AddText(v_text);

            v_object = new Spartacus.Game.Object("throw", 700, 450, 32, 32);
            v_object.AddImage("gui/throw.png");
            v_object.AddImage("gui/throw_" + this.v_player + ".png");
            this.v_guiview.AddObject(v_object);

            v_text = new Spartacus.Game.Text(750, 455, "Courier New", 12, 255, 255, 255, 255);
            v_text.SetMessage("Throw");
            this.v_guiview.AddText(v_text);

            v_object = new Spartacus.Game.Object("endturn", 700, 500, 32, 32);
            v_object.AddImage("gui/endturn.png");
            this.v_guiview.AddObject(v_object);

            v_text = new Spartacus.Game.Text(750, 505, "Courier New", 12, 255, 255, 255, 255);
            v_text.SetMessage("End Turn");
            this.v_guiview.AddText(v_text);
        }
示例#3
0
 public void AddText(Spartacus.Game.Text p_text)
 {
     this.v_texts.Add(p_text);
 }