blob: a005c562b654a585f6ea84cc729d1c30e68b03d4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GameEngine;
namespace SpaceInvaders {
class Program {
static void Main(string[] args) {
Game SpaceInvaders = new SpaceInvaders();
SpaceInvaders.Setup();
SpaceInvaders.Start();
}
}
class SpaceInvaders : Game {
public override void Setup() {
// This sub is meant for setting the properties of the GameEngine. DO NOT MAKE NEW ONES HERE
// IMPORTANT! You might have to change the console font size, depending on how many rows and columns you want to have!
ConsoleWidth = 600; // Bigger than 15
ConsoleHeight = 120; // Bigger than 15
}
public override void Start() {
// Initialize all gameobjects here
GameObject gameLogic = new GameLogic();
gameLogic.Parent = this;
GameObjects.Add(gameLogic);
// Initialize the player
GameObject player = new Player();
player.Parent = this;
player.xPos = ConsoleWidth / 2 - 10;
player.yPos = 115;
player.Scale = 1;
GameObjects.Add(player);
// Init Obstacles
for (int i = 0; i < 6; i++) {
GameObject obstacle = new Obstacle();
obstacle.Parent = this;
obstacle.xPos = 50 + (i * 90);
obstacle.yPos = 90;
GameObjects.Add(obstacle);
obstacle = new Obstacle();
obstacle.Parent = this;
obstacle.xPos = 50 + (i * 90) + 8;
obstacle.yPos = 90;
GameObjects.Add(obstacle);
obstacle = new Obstacle();
obstacle.Parent = this;
obstacle.xPos = 50 + (i * 90) + 16;
obstacle.yPos = 90;
GameObjects.Add(obstacle);
obstacle = new Obstacle();
obstacle.Parent = this;
obstacle.xPos = 50 + (i * 90) + 24;
obstacle.yPos = 90;
GameObjects.Add(obstacle);
obstacle = new Obstacle();
obstacle.Parent = this;
obstacle.xPos = 50 + (i * 90) + 32;
obstacle.yPos = 90;
GameObjects.Add(obstacle);
obstacle = new Obstacle();
obstacle.Parent = this;
obstacle.xPos = 50 + (i * 90);
obstacle.yPos = 90 + 4;
GameObjects.Add(obstacle);
obstacle = new Obstacle();
obstacle.Parent = this;
obstacle.xPos = 50 + (i * 90) + 32;
obstacle.yPos = 90 + 4;
GameObjects.Add(obstacle);
}
base.Start(); // Do start from inherited class, Required for the engine to actually start
}
}
}
|