'// UnseenGDK - For UnseenGDK03 and up.'//'// ##################### Indepth Tutorial Set 1 ##################################'// ===== Base commands and TYPE's, what they are, how to use them and more.. ====='// ###############################################################################'//'//'// !!!!! PLEASE NOTE !!!!!'// This demo uses the QB64 Logo which can be downloaded from the QB64 website (The bee on honeycomb)'// (right click it, copy and save in paint as QBLogo.png in your QB64 folder).'//'//'// ####################################'// Part 1 - The basics of UnseenGDK'// ####################################'//'// INCLUDING THE LIBRARY...'//'// To use anything from the UnseenGDK library you must include a referance to it within your code. This is'// usually placed at the bottom of a program, (this may not all ways be the case but thats for later).'// REM $INCLUDE:'UnseenGDK03.bm''//'//'// BASE TYPES AND THEIR BASIC USAGE COMMANDS'//'// UnseenGDK has several base types. These types are the core of UnseenGDK.'// The command GDK_Start must be called for a program to have access to these type's.'//'// The types initiated by GDK_Start are:'// Texture, Vector2D, Rectangle, MP3, MouseState, KeyboardState, PolygonPoint, GameObject and BlittingRect'//'// With these TYPE definitions and their associated commands it is possible to make a simple 2D game very quickly.'//'// *** CODE ***GDK_Start'//'// CREATING A PROGRAM SCREEN'//'// To create a program screen, which is needed before you can do any drawing or loading of images, use the command'// GDK_SetScreenRes'//'* COMMAND REF:'* GDK_SetScreenRes (ScreenHandle&, width%, height%, clr%, fs%)'//'// ScreenHandle& = The handle to attribute to the screen.'// width% = The width of the screen (In pixels)'// height% = The height of the screen (In pixels)'// clr% = The color attibutes of the screen, MUST BE 32!!'// fs% = Fullscreen mode option, 1 = Fullscreen, 0 = Not fullscreen.'//'// *** CODE ***GDK_SetScreenRes MainScreen, 600, 400, 32, 0'// This will create a screen 600*400 with 32 bit colors in normal window mode (not fullscreen).'// Now your ready to start loading and drawing stuff.'//'//'// The most important of the base types are Texture, Vector2D, Rectangle, KeyboardState and MouseState.'// The basics of using these types will be covered here.'//'// Texture - Then texture type deals with anything to do with graphics in your game, it contains the following'// variables:'//'// File AS LONG - The handle of the image being loaded.'// Width AS INTEGER - The Width of the image being loaded.'// Height AS INTEGER - The heigt of the image being loaded.'// Alpha AS LONG - The alpha(transparent) color of the image being loaded.'// IsVisible AS INTEGER - Determines if an image can be drawn or not.'// XFrameCount AS INTEGER - The number of animation frames in the X axis.'// YFrameCount AS INTEGER - The number of animation frames on the Y axis.'// TotalFrameCount AS INTEGER - The total number of animation frames.'// RotationX AS INTEGER - The point at which an image will be rotated on the X axis.'// RotationY AS INTEGER - The point at which an image will be rotated on the Y axis.'// Scale AS SINGLE - The scale to draw the image.'//'// First you MUST dimension your Texture in memory. This is done just as you would dimension an Integer, String'// or any other varible or type. As with all other varibles you can have arrays of Textures.'// *** CODE ***DIM MyImage AS Texture '// MyImage is now a Texture.'// Now you can load your image into memory and set it's variables.'// NOTE!!! GDK DOES NOT PERFORM ANY CHECK FOR THE IMAGE FILES EXISTANCE!!!'// To set the majority of the varibles for any given image requires the command GDK_NewTexture.'//'* COMMAND REF :'* GDK_NewTexture (TextureFile AS Texture, FileSource$, XFrameCount%, YFrameCount%, TotalFrameCount%, Scale!)'//'// TextureFile - The name of the texture type, in this program MyImage'// FileSource$ - The location of the image, e.g "C:\pictures\Images1.png"'// XFrameCount% - The number of frames on the X axis.'// YFrameCount% - The number of frames on the Y axis.'// TotalFrameCount% - The total number of frames in the image.'// Scale! - The size to draw the image, 1 = normal, .5 = half , 2 = double etc...'//'// The Qb64 logo image only has 1 frame on the x axis and 1 frame on the y axis, so 1 frame in total.'//'// *** CODE ***GDK_NewTexture MyImage, "QbLogo.png", 1, 1, 1, 1'// The image is now in memory but cannot be drawn as it is invisible! To make the image visible use the command'// GDK_SetTextureVisibility.'//'* COMMAND REF:'* GDK_SetTextureVisibility (TextureFile AS Texture, OnOff%)'//'// TextureFile - The name of the texture file to be set.'// OnOff% = Visibility factor , -1 = Visible, 0 = not visible'//'// *** CODE ***GDK_SetTextureVisibility MyImage, -1'//'// Now the image is loaded into memorya and set to be visible it is ready to use.'// To draw a texture on the screen you must first desginate where you will draw it. This is done with the'// Vector2D type.'//'// Vector2D - Handles position, rotation and movement of a texture.'//'// X AS SINGLE - X position.'// Y AS SINGLE - Y position.'// Speed AS SINGLE - Current speed.'// Rotation AS DOUBLE - Rotation amount, in radians.'// Accel AS SINGLE - Acceleration factor.'// Decel AS SINGLE - Decleraration factor.'//'// As with Texture's you must first dimension your Vector2D in memory.'//'// *** CODE ***DIM MyImagePos AS Vector2D '// MyImagePos is now a Vector2D'// Now you can assign values to the Vector2D. The Accel and Decel are more advanced features and are not covered here.'// To assign values to the Vector2D use the command GDK_NewVector2d'* COMMAND REF:'* GDK_NewVector2D (Vector AS Vector2D, X%, Y%, Speed!, Rotation#)'//'// Vector - The name of the Vector2D to apply the values to, here it is MyImagePos'// X% - The X axis position.'// Y% - The Y axis position'// Speed! - The speed.'// Rotation# - The rotation value (in radians).'//'// *** CODE ***GDK_NewVector2D MyImagePos, 300, 200, 0, 0'// Now all thats left is to draw the image.'// This is doen with the command GDK_DrawTexture'//'* COMMAND REF:'* GDK_DrawTexture (TextureFile AS Texture, DestVector AS Vector2D, Frame%)'//'// TextureFile - The name of the Texture to be drawn.'// DestVector - The name of the Vector2D at which to draw the image.'// Frame% - The frame of the image to draw. Use 0 to draw the entire image.'//'// *** CODE ***GDK_DrawTexture MyImage, MyImagePos, 0'// REMEMBER TO INCLUDE THE LIBRARY :)'// *** CODE ***REM $INCLUDE:'UnseenGDK03.bm'
GDK_StartGDK_SetScreenRes MainScreen, 600, 400, 32, 0DIM MyImage AS Texture '// MyImage is now a Texture.GDK_NewTexture MyImage, "QbLogo.png", 1, 1, 1, 1GDK_SetTextureVisibility MyImage, -1DIM MyImagePos AS Vector2D '// MyImagePos is now a Vector2DGDK_NewVector2D MyImagePos, 300, 200, 0, 0GDK_DrawTexture MyImage, MyImagePos, 0REM $INCLUDE:'UnseenGDK03.bm'