JEmpty.cs

This file represents the base application for Jad. You´ll have to override the InitGame, Action and Render methods and you are set ;)

#region Using directives

using System.Windows.Forms;

using JadEngine;
using JadEngine.Video;
using JadEngine.Core;
using JadEngine.Input;

#endregion

namespace Tutorial
{
	/// <summary>
	/// Default basic class to create a Jad application
	/// </summary>
	public class EmptyProject : JApplication
	{
		#region Methods

		/// <summary>
		/// The engine calls this method after creating the device
		/// </summary>
		/// <param name="form">Form used as window</param>
		/// <returns>True if everything went right</returns>
		public override bool InitGame(Form form)
		{
			// Create the fonts and texture objects
			Jad.AfterCreateDevice();

			// Load default textures, scenes, shaders,...
			Jad.LoadCreateInHouse();

			// Here goes the code to load and start the application

			// Everything is set, start the engine
			Jad.Begin();

			// Create input class to manage the keyboard and the mouse
			Jad.CreateInput();

			return true;
		}

		/// <summary>
		/// This method is called every frame and it´s where the input
		/// events and the game action must be placed
		/// </summary>
		/// <returns>True to continue, false to exit the application</returns>
		public override bool Update()
		{
			// Exit the app?
			if (Jad.Input.Keyboard[Key.Escape].Down) return false;

			// Everything was right, continue
			return true;
		}

		/// <summary>
		/// Render method
		/// </summary>
		public override void Render()
		{
			// The views are render 'windows'. The engine creates the implicit
			// view, the backbuffer, by default.

			JView backbuffer = Jad.Video.Views[0];

			// Render the Jad.Scene using the scene camera
			backbuffer.Render();

			// Get access to the 1st font. The engine creates a font by default
			JFont font = Jad.Video.Fonts[0];

			// Start fonts rendering
			Jad.Video.Fonts.Begin();

			/// Write text in the first line, position x=0, yellow color
			font.RenderLine(Jad.Version + " Press ESC to exit", 0, JColor.Yellow);

			// Write text in the second line, position x=0, white color
			font.RenderLine(Jad.Video.Views.CurrentView.Stats.Fps + " FPS", 0, JColor.White);

			// End fonts rendering
			Jad.Video.Fonts.End();

			// Show the backbuffer
			backbuffer.Present();
		}

		#endregion
	}
}

Last edited Mar 6, 2007 at 4:20 PM by Vicente, version 6

Comments

No comments yet.