Jump to content
  • Advertisement
Sign in to follow this  
  • entry
  • comments
  • views

SimpleRTS Update #1

Sign in to follow this  
Narf the Mouse


Most of my programming has been hobbyist-theoretical and reading more blogs than is probably healthy. I'm sick of it. I wanna make a game.

I'm going to make a game, using my current game engine.

Presenting SimpleRTS Update 1:

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using Game_Engine_Toolkit;

namespace SimpleRTS
static class Program
static System.Diagnostics.Stopwatch watch =
static double lastSecond = 0.0;
static double deltaSeconds = 0.0;

static Display display = null;
static Scene scene = null;
static Keyboard keyboard = null;
static Vector3 cameraPoint = Vector3.Zero;
static float cameraHeight = 256;
static float minCameraHeight = 32;
static float maxCameraHeight = 768;
static string groundName = "Ground";
static string mainCameraName = "Main Camera";

/// The main entry point for the application.

static void Main()
display = new Display(
typeOfDevice: DeviceType.DirectX9,
threaded: Threaded.SingleThreaded,
screenMode: ScreenMode.Windowed,
onDeviceLost: OnDeviceLost,
onDeviceReset: OnDeviceReset,
title: "Simple RTS",
displayWidth: 1024,
displayHeight: 768

scene = new Scene(display);

keyboard = new Keyboard();

Mesh ground = scene.CreateMesh(groundName);
ground.SetCube(1024, 1, 1024);
ground.MaterialDiffuseColourDrawing = Color.SandyBrown;
ground.MaterialSpecularColourDrawing = Color.SandyBrown;
ground.MaterialSpecularColourVector *= 0.5F;
ground.LocalMatrix = Matrix4x4.Translation(Vector3.Down * 0.5F);

cameraPoint = new Vector3(-384, 0, -384);

Camera camera = scene.CreateCamera(mainCameraName);
camera.SetPerspective(Utility.DegreesToRadians(65), display.AspectRatio, 0.001F, 10000);
camera.SetLookAt(cameraPoint + new Vector3(0, cameraHeight, -64), cameraPoint, Vector3.Up + Vector3.Forward);

Light light = scene.CreateLight("Sunlight");
on: true,
direction: new Vector3(-55, -35, 1),
diffuseColour: Color.LightGoldenrodYellow,
specularColour: Color.LightGoldenrodYellow,
specularExponent: 1,
intensity: 0.8F

lastSecond = watch.Elapsed.TotalSeconds;
while (!display.Closed)
deltaSeconds = watch.Elapsed.TotalSeconds - lastSecond;
lastSecond = watch.Elapsed.TotalSeconds;
float deltaSecondsUse = (float)deltaSeconds;


if (keyboard.State.KeyDown(Key.Escape))

if (keyboard.State.KeyDown(Key.PageUp))
cameraHeight = Math.Min(cameraHeight + (cameraHeight * deltaSecondsUse), maxCameraHeight);
if (keyboard.State.KeyDown(Key.PageDown))
cameraHeight = Math.Max(cameraHeight - (cameraHeight * deltaSecondsUse), minCameraHeight);

scene.GetCamera(mainCameraName).SetLookAt(cameraPoint + new Vector3(0, cameraHeight, -64), cameraPoint, Vector3.Up + Vector3.Forward);



foreach (var light in scene.Lights)
foreach (var camera in scene.Cameras)

foreach (var mesh in scene.Meshes)



catch (Exception e)

private static void OnDeviceLost()
if (scene != null) scene.Release();
private static void OnDeviceReset()
if (scene != null) scene.Reload();
Sign in to follow this  


Recommended Comments

Well... It's step 1 :)
Next time, could you post some screenshot too, or some explanation of your code ? (for now it's simple enough to read but well... someday you'll have a game !!!!!)
Good luck !

Share this comment

Link to comment
I'm going to make a game...<INSERTS CODE>

but seriously an RTS is a nice idea. Now I wish I was making an RTS too. Maybe my next project (ie 2014). You going to make it singleplayer or multiplayer?

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!