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(); }
private void BuildMapView() { Spartacus.Game.Object v_object; this.v_mapview.v_objects.Clear(); this.v_soldiersview.v_objects.Clear(); for (int x = 0; x < this.v_mapview_width; x++) { for (int y = 0; y < this.v_mapview_height; y++) { v_object = new Spartacus.Game.Object(this.v_tile_size * x, this.v_tile_size * y, this.v_tile_size, this.v_tile_size); v_object.AddImage(this.v_tileset[this.v_mapview_x + x, this.v_mapview_y + y].GetImage()); this.v_mapview.AddObject(v_object); for (int w = 0; w < this.v_soldiers.Length; w++) { if (this.v_soldiers[w].v_mapx == (this.v_mapview_x + x) && this.v_soldiers[w].v_mapy == (this.v_mapview_y + y)) { this.v_soldiers[w].v_object.SetPosition(this.v_tile_size * x, this.v_tile_size * y); this.v_soldiersview.AddObject(this.v_soldiers[w].v_object); if (this.v_soldiers[w].v_color == this.v_turn) { if (this.v_soldiers[w].v_actions > 0) { this.v_soldiers[w].v_object.SetBorder(System.Drawing.Color.White, this.v_border_width); } else { this.v_soldiers[w].v_object.SetBorder(System.Drawing.Color.Black, this.v_border_width); } } } } } } }
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); }