How To Draw Simple Text

In SwinGame you will often need to draw text to the screen to label something, show game scores or simply prompt the user for something.  this beginner level how to explains how to draw text to the game window.

howtodrawsimpletext

Level

Beginner

Read these first

How To Refresh The Screen

Details

To draw basic text to the game window you need to stipulate four arguments. The 'Test to display', the Color and the X and Y position in the game Window you need to display the text.

You can read about the DrawText function in the Text API

Remember to use the American spelling of the word Color


Source Code Widget

  • program HowToDrawSimpleText;
    uses SwinGame,sgTypes;
    
    procedure Main();
    
    begin
        OpenGraphicsWindow('Drawing Text' ,800 ,600 );
        ClearScreen();
        DrawText('You Win!!!' ,ColorWhite ,300 ,200 );
        RefreshScreen();
        Delay(5000 );
        ReleaseAllResources();
    end;
    begin
        Main();
    end.
    Download Now"
  • #include 
    #include "SwinGame.h"
    int main() 
    {
    
        open_graphics_window("Drawing Text" ,800 ,600 );
        clear_screen();
        draw_text("You Win!!!" ,color_white ,300 ,200 );
        refresh_screen();
        delay(5000 );
        release_all_resources();
        return 0;
    }
    
    Download Now"
  • Source Code Coming Soon

  • Source Code Coming Soon

  • Source Code Coming Soon


Possibilities

  • Create custom messages for your friends
  • Create a story program, draw text then delay, clear the screen draw the next part of the story. Be creative use different colors for the background and text!