HGE small demo #2: using images from the DataSection
Posted: Thu Jul 10, 2008 2:41 am
Hi, guys.
This would be another tiny example on how to include images in the executable and use them with HGE. Replace the #PROJECT_PATH and the image file at will.
This would be another tiny example on how to include images in the executable and use them with HGE. Replace the #PROJECT_PATH and the image file at will.
Code: Select all
IncludeFile "..\HGEWrapper_Include.pbi"
Structure sprite
x.f
y.f
w.l
h.l
speed.f
sprite.l
tex.l
EndStructure
#PROJECT_PATH = "C:\Purebasic\HGE\Projeto\"
#SCREEN_WIDTH = 320
#SCREEN_HEIGHT = 240
Global img.sprite
ProcedureCDLL frameFunc()
If hge_Input_GetKeyState(#HGEK_ESCAPE)
ProcedureReturn #True
EndIf
ProcedureReturn #False
EndProcedure
ProcedureCDLL renderFunc()
hge_Gfx_BeginScene(#Null)
hge_Gfx_Clear(0)
hge_Sprite_Render(img\sprite, #SCREEN_WIDTH/2-img\w/2, #SCREEN_HEIGHT/2-img\h/2)
hge_Gfx_EndScene()
ProcedureReturn #False
EndProcedure
hge_Create(#HGE_VERSION)
hge_System_SetStateBool(#HGE_WINDOWED, #True)
hge_System_SetStateString(#hge_LOGFILE, #PROJECT_PATH + "byo_demo.log")
hge_System_SetStateFunc(#HGE_FRAMEFUNC, @frameFunc())
hge_System_SetStateFunc(#hge_RENDERFUNC, @renderFunc())
hge_System_SetStateBool(#hge_SHOWSPLASH, #False)
hge_System_SetStateString(#HGE_TITLE, "byo demo")
hge_System_SetStateBool(#HGE_USESOUND, #False)
hge_System_SetStateInt(#hge_SCREENWIDTH, #SCREEN_WIDTH)
hge_System_SetStateInt(#hge_SCREENHEIGHT, #SCREEN_HEIGHT)
hge_System_SetStateInt(#hge_SCREENBPP, 32)
If hge_System_Initiate()
img\w = 48
img\h = 39
img\tex = hge_Texture_Catch(?img1, ?img1End-?img1)
img\sprite = hge_Sprite(img\tex, 0, 0, img\w, img\h)
hge_System_Start()
hge_System_Shutdown()
hge_Release()
EndIf
DataSection
img1: IncludeBinary "shuttle.png" : img1End:
EndDataSection