[SDL] Test programs

MrTAToad mrtatoad at mrtatoad.plus.com
Sun Sep 28 04:17:46 PDT 2014


I've got a set of SDL2 test programs here : https://onedrive.live.com/redir?resid=DD5B5E7788984419!6233&authkey=!ACvDUUgC1vgaDZU&ithint=file%2crar

With the exception of the starfield and sprite speed tester (of which the latter will show the SDL_CreateWindow problem), most of these examples are simple test programs for my Triority system - essentially, its a program processing system based on GLBasic.  I did this in case the author of GLBasic decided to stop updates (which have been slowing down for a while anyway), and thus would allow me to convert code fairly simply.

But I digress...

Some piccies : https://onedrive.live.com/redir?resid=DD5B5E7788984419!6234&authkey=!AGhAA-GmihPxM4o&v=3&ithint=photo%2cpng and https://onedrive.live.com/redir?resid=DD5B5E7788984419!6235&authkey=!AG218rqhJX-BpaE&v=3&ithint=photo%2cpng

The starfield code is :


Code:
#include "Triority.h"

int main(int argc, char * argv[])
{
	DGArray<DGInt> stars;
	DGNat scx, scy;
	const char *organisation = "Triority";
	const char *programName = "Starfield";

	if (__GLB_Defaults(argc, argv, organisation, programName) == false)
	{
		END();
	}

	GETSCREENSIZE(scx, scy);
	SYSTEMPOINTER(false);

	LOADSOUND("3.ogg", 0);
	LOADSOUND("2.ogg", 1);
	LOADSOUND("1.ogg", 2);
	LOADSOUND("go.ogg", 3);

	for (int i = 0; i<4; i++)
	{
		PLAYSOUND(i, 0.0, 100.0);
		while (SOUNDPLAYING(i))
		{
			SHOWSCREEN();
		}
	}

	PLAYMUSIC("romancandle_30.ogg", false);

	DIM(stars, 1001, 6);
	for (int i = 0; i<1001; i++)
	{
		stars(i, 0) = RND(4000) - 2000;
		stars(i, 1) = RND(4000) - 2000;
		stars(i, 2) = RND(4000) + 1000;
		stars(i, 5) = (25 + RND(100));
	}

	while (true)
	{		
		for (int i = 0; i<1001; i++)
		{
			stars(i, 2) = stars(i, 2) - stars(i, 5); // speed
			if (stars(i, 2) <= 0)
			{
				stars(i, 0) = RND(4000) - 2000;
				stars(i, 1) = RND(4000) - 2000;
				stars(i, 2) = RND(4000) + 1000;
				stars(i, 5) = (25 + RND(50))*GETTIMER() / 25;
			}
			stars(i, 3) = (stars(i, 0) * 100) / stars(i, 2);
			stars(i, 4) = (stars(i, 1) * 100) / stars(i, 2);
			SETPIXEL(scx / 2 + stars(i, 3), scy / 2 + stars(i, 4), GLRGB(255, 255, 255));
		}

		ALPHAMODE(1.0);
		PRINT("FPS : " + FORMAT_Str(4, 4, GETFPS()), 0, 0, false);
		PRINT("Is full screen : " + FORMAT_Str(2, 0, ISFULLSCREEN()), 0, 16, false);
		PRINT("Resolution : " + FORMAT_Str(4, 0, scx) + " x " + FORMAT_Str(4, 0, scy), 0, 32, false);
		PRINT("Press ALT+RETURN to switch between full screen and  window mode", 0, 48, false);
		PRINT("Time : " + PLATFORMINFO_Str("TIME"), 0, 64, false);
		PRINT("Battery : " + PLATFORMINFO_Str("BATTERY"), 0, 84, false);

		SHOWSCREEN();
	}

	return 0;
}






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20140928/ab4afac4/attachment-0002.htm>


More information about the SDL mailing list