Advertisement
ASP_Volume2 Miscellaneous #40803

MasterX SDK Tutorial

A tutorial for beginers, for starting off with masterX SDK to create 2D video games.

AI

AI Samenvatting: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Broncode
original-source
<HTML>
<BODY>
<FONT COLOR="#BD0000" FACE="FIXEDSYS">
<img src="http://www.lostsidedead.com/psccd2/intro.jpg"><br>
<u> MasterX SDK Tutorial </u><br><br>
<b> What is MasterX SDK? </b><br><br>
MasterX SDK is a series of classes and functions which aid you
in DirectX Game programming. It encapsulates a great deal of DirectX
so you can quickly and easily pump out a 2D video game with ease.
It contains a wide array of functionality ranging from Graphics,
to Sound, to Windows Sockets, to playing mp3's. Not only is the implementaion
easy to grasp, but its also a snap to use.<br><br>
<b> What is DirectX? </b><br><br>
DirectX is a series of COM Objects from Microsoft that allow you to get 
down to a lower level then the GDI (Graphics Device Interface) and is 
much faster. DirectX contains many features, and is the actual API behind MasterX. <br><br>
<b> So Why MasterX SDK?</b><br><br>
DirectX API isnt exactly the most beautiful api in exisitance, it has its flaws, and its complexitys that for most 
applications are unnessicary. Through using C++ classes we can encapsulate the difficult aspects of directX , and just get 
down to are game. Most video games in existence
first create an "engine" (or SDK), for the game, and then use that when
buliding the game. So MasterX SDK you could say is a 2D game engine that
wraps around DirectX. <br><br>
<b> Who Should use MasterX </b><br><br>
People who have no eXPerience with DirectX at all. You can ease your self into DirectX API, or complety skip learning it to 
produce that game you have been dreaming about. After writing a few applications with MasterX SDK, when you go to learn 
actual DirectX api, it will come to you alot easyier because you will have already learned and used some of the 
concepts.<br><br>
<b> So Whats a MasterX Program Look Like?</b><br><br>
If you have done console programming before, you will remember that your program starts with a main function. This function 
acts as the entry point
and is the start of your programs execution. Well with MasterX SDK, you have a starting point, the difference is instead of 
being called main, it is called MasterMain , its prototype is as follows<br><br>
<font color="blue"> int MasterMain(HINSTANCE hInst,LPSTR cmdline);</font><br><br>
<Br><br> when the program begins execution the MasterMain function is called , and then triggers the events for your 
application to occour. Now before we go any further I would like to explain the phillosphy behind how the MasterX SDK engine 
works. As said in the words of the masters , to be one with your enviorment is to be as I am. This concept is used in the 
creation of the engine and makes the proccess much simpiler. All calls to make changes in the enviorment come from 1 source, 
the MasterXHWND. The MasterXHWND has the abilty to draw text to the screen, paint shapes, and give have off spring graphics 
which point to it. It is a very important aspect of the engine and is what makes the changes. It encapsulates all of DirectX 
functionality and gives you one simple interface to manipulate the Opearting System. Now that we understand the concept of 
'Master' X sdk,
lets take a look at a example masterX SDK program, and ill explain it line by line.
<br><br> <u>code example</u> <br><br>
<font color="green">
/* masterX hello world example<br>
 written by Jared Bruni<br>
 www.LostSideDead.com<br>
<br>
 "Open Source, Open Mind"<br>
*/
// define the MasterX SDK</font><br>
#define MASTERXSDK<br>
#include"masterlibrary2.h"<font color="green">// include masterlibrary <br>
// function prototypes<br></font>
long _stdcall event(struct HWND__* hwnd,unsigned int msg, unsigned int wparam, long lparam);<br>
void update(MASTERSCREEN screen);<br>
<font color="green">// the MasterX hwnd</font><br>
MasterXHWND mxhwnd;<br>
<br>
<font color="Green">// initilization</font><br>
int _stdcall MasterMain(struct HINSTANCE__* hInst,char* line)<br>
{<br>
	<font color="green">// create MasterX initilize the screen</font><br>
	if(mxhwnd.CreateMasterX("MyProgram",640,480,COLOR_DEFAULT,event,hInst,NULL,NULL))<br>
	{<br>
		return (mxhwnd.InitLoop(update)); <br><font color="green">
		/*initilize the game loop<br>
		whatever function you have this point to<br>
		 will be called every update the screen makes<br>
		 use this to draw your frames */</font><br>
	} <br>
	return (0);<br>
}<br>
<font color="green">/* call back function for events, like keypresses and mouse moves */</font><br>
long _stdcall event(struct HWND__* hwnd,unsigned int msg, unsigned int wparam, long lparam)<br>
{<br>
	switch(msg)<br>
	{<br>
	case WM_DESTROY:<br>
		PostQuitMessage(0);<br>
		break;<br>
	case WM_ACTIVATEAPP:<br>
		mxhwnd.activeapp = wparam;<br>
		break;<br>
	case WM_KEYDOWN:<br>
		{<br>
			mxhwnd.Kill();<font color="green">// stop the programs execution</font><br>
		}<br>
		break;<br.
	default: return DefWindowProc(hwnd,msg,wparam,lparam);<br>
	}<br>
	return (0);<br>
}<br>
<font color="green">/* heres the important update function which we pointed to during initilization */</font><br>
void update(MASTERSCREEN screen)<br>
{<br>
	mxhwnd.text.printtext("Hello World Press Escape to Exit..",10,10);<br>
	<font color="green">// every frame update draw this to the screen</font><br>
}<br>
<br><br>
<b> Output of the code </b><br><br>
<img src="http://www.lostsidedead.com/mx/output.jpg"><br><br>
<b> Download Source Code form Tutorial </b><br><br>
<a href="http://www.lostsidedead.com/mx/mxhello.zip">Hello World with masterX SDK </a><br><br><a href="http://planetsourcecode.com/xq/ASP/txtCodeId.2588/lngWId.3/qx/vb/scripts/ShowCode.htm"> Knights tour Example</a><br><br>
<br> <b> There are over 50 masterX examples,
just do a search for MasterX SDK </b><br><br> 
</FONT>
</BODY>
</HTML>
Originele reacties (3)
Hersteld van de Wayback Machine