I just made this small demo using linked lists. It does nothing special right now, it was written just to show the usage of linked lists and to add to the HGE examples.
It may be helpful to those who just started using HGE with Purebasic to set things up properly and make a first demo run.
You can download all the resources below (I'm not the author of any of those images):
http://rapidshare.com/files/128501932/H ... o.zip.html
[EDIT] : you must change the #PROJECT_PATH constant.
Code: Select all
IncludeFile "..\HGEWrapper_Include.pbi"
Structure hgeRect
x1.f
x2.f
y1.f
y2.f
EndStructure
Structure sprite
x.f
y.f
w.l
h.l
speed.f
sprite.l
tex.l
EndStructure
Global player.sprite
player\x = 303.0
player\y = 410.0
player\w = 48
player\h = 39
player\speed = 0.2
Global NewList bullet.sprite()
Global NewList block.sprite()
Global bulletsOnScreen.l
#PROJECT_PATH = "C:\Purebasic\HGE\Projeto\"
#SCREEN_WIDTH = 640
#SCREEN_HEIGHT = 480
#MAX_BULLETS = 12
ProcedureCDLL frameFunc()
If hge_Input_GetKeyState(#HGEK_ESCAPE)
ProcedureReturn #True
EndIf
If hge_Input_GetKeyState(#HGEK_RIGHT)
player\x + player\speed
If player\x > #SCREEN_WIDTH - player\w
player\x = #SCREEN_WIDTH - player\w
EndIf
EndIf
If hge_Input_GetKeyState(#HGEK_LEFT)
player\x - player\speed
If player\x < 0
player\x = 0
EndIf
EndIf
If hge_Input_KeyDown(#HGEK_SPACE)
If bulletsOnScreen < #MAX_BULLETS
AddElement(bullet())
bullet()\x = player\x + player\w/2 - 5
bullet()\y = player\y - 10
bullet()\w = 10 : bullet()\h = 10
bullet()\tex = hge_Texture_Load(#PROJECT_PATH + "bullet.png")
bullet()\sprite = hge_Sprite(bullet()\tex, 0, 0, bullet()\w, bullet()\h)
hge_Sprite_SetBlendMode(bullet()\sprite, #BLEND_COLORMUL|#BLEND_ALPHAADD|#BLEND_NOZWRITE)
bulletsOnScreen + 1
EndIf
EndIf
ForEach bullet()
bullet()\y - 0.3
ResetList(block())
While NextElement(block())
If (bullet()\x+bullet()\w >= block()\x And bullet()\x < block()\x+block()\w) And (bullet()\y+bullet()\h >= block()\y And bullet()\y < block()\y+block()\h)
DeleteElement(block(), 1)
DeleteElement(bullet(), 1)
bulletsOnScreen -1
Break
EndIf
If bullet()\y < -10
DeleteElement(bullet(), 1)
bulletsOnScreen - 1
Break
EndIf
Wend
Next
ProcedureReturn #False
EndProcedure
ProcedureCDLL renderFunc()
hge_Gfx_BeginScene(#Null)
hge_Gfx_Clear(0)
hge_Sprite_Render(player\sprite, player\x, player\y)
ForEach block()
hge_Sprite_Render(block()\sprite, block()\x, block()\y)
Next
ForEach bullet()
hge_Sprite_Render(bullet()\sprite, bullet()\x, bullet()\y)
Next
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_SCREENHEIGHT, #SCREEN_HEIGHT)
hge_System_SetStateInt(#hge_SCREENWIDTH, #SCREEN_WIDTH)
hge_System_SetStateInt(#hge_SCREENBPP, 32)
If hge_System_Initiate()
player\tex = hge_Texture_Load(#PROJECT_PATH + "shuttle.png")
player\sprite = hge_Sprite(player\tex, 0, 0, player\w, player\h)
hge_Sprite_SetBlendMode(player\sprite, #BLEND_COLORMUL|#BLEND_ALPHAADD|#BLEND_NOZWRITE)
#blocksize = 32
For y.l = 0 To 320 Step #blocksize
For x.l = 0 To 640 Step #blocksize
AddElement(block())
block()\x = x
block()\y = y
block()\w = #blocksize
block()\h = #blocksize
block()\tex = hge_Texture_Load(#PROJECT_PATH + "block.png")
block()\sprite = hge_Sprite(block()\tex, block()\x, block()\y, block()\w, block()\h)
hge_Sprite_SetBlendMode(block()\sprite, #BLEND_COLORMUL|#BLEND_ALPHAADD|#BLEND_NOZWRITE)
Next
Next
hge_System_Start()
hge_System_Shutdown()
hge_Release()
EndIf

