-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.bas
More file actions
85 lines (67 loc) · 2.73 KB
/
Copy pathtest.bas
File metadata and controls
85 lines (67 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "Tilengine.bi"
#define ScrWIDTH 320
#define ScrHEIGHT 240
'*** this just assign names to our layers ***
'*** those are not used yet as we have no tiles ***
enum
LAYER_OVERLAY
LAYER_FOREGROUND
MAX_LAYER
end enum
'*** select the base path for the assets ***
'*** so we wont need this (as default is app folder) ***
TLN_SetLoadPath("assets/_png")
'*** initializing the screen ***
TLN_Init(ScrWIDTH, ScrHEIGHT, MAX_LAYER,1,3)
'load our bitamps
dim shared as TLN_Bitmap bmBackground , bmSprites , bmMist
bmBackground = TLN_LoadBitmap("background.png")
bmSprites = TLN_LoadBitmap("sprites.png")
bmMist = TLN_LoadBitmap("mist.png")
'*** Create the window... and disable the CRT effect ***
'*** the window is created with 2x scale... ***
'*** and "nearest" filter (no resize blur) ***
TLN_CreateWindow (null, CWF_S2 or CWF_NEAREST)
TLN_DisableCRTEffect()
'we will use the background as an image...
'while tiled games usually have them as a "color"
'our bitmap is 320x240 just like our Screen width
'otherwise we would need to scale it to cover everything
TLN_DisableBGColor ()
TLN_SetBGBitmap( bmBackground )
TLN_SetLayerBitmap( LAYER_OVERLAY , bmMist )
TLN_SetLayerBlendMode( LAYER_OVERLAY , BLEND_MIX25 , 0 )
'set mist layer
'*** this is the main loop ***
'*** TLN_ProcessWindow() process the events for the engine ***
'*** it reads pending events like INPUT events or quit event ***
dim as integer iFrameNum = 0, iMistX, iMistY
dim as integer iMistWid = TLN_GetBitmapWidth( bmMist )
dim as integer iMistHei = TLN_GetBitmapHeight( bmMist )
dim as TLN_Affine affine : affine.sx = 1 : affine.sy = 1
dim as longint llOldTicks, llFrameTicks, llLimitTicks
dim as integer iFPS
const TPS = 6000, cEngineFPS = 30, cLimitFps = 10
#define Ticks() (TLN_GetTicks()*clngint(6))
while (TLN_ProcessWindow())
if abs(Ticks()-llFrameTicks) > TPS then llOldTicks = Ticks()
if abs(Ticks()-llFrameTicks) > TPS then
TLN_SetWindowTitle("TileEngine: " & iFPS & " fps")
iFPS = 0 : llFrameTicks=Ticks()
end if
do
if abs(Ticks()-llOldTicks) < (TPS\cEngineFPS) then exit do
TLN_SetLayerPosition( LAYER_OVERLAY , iMistX , iMistY )
TLN_SetLayerAffineTransform(LAYER_OVERLAY, @affine)
affine.angle += .05
if (iFrameNum and 1) then
iMistX = (iMistX+1) mod iMistWid
iMistY = (iMistY+1) mod iMistHei
end if
iFrameNum += 1 : llOldTicks += (TPS\cEngineFPS)
loop
'*** draws the frame... "iFrameNum" is for the engine ***
'*** to know in which frame an animated sprite/tile is ***
'*** as those can be handled automatically by the engine ***
TLN_DrawFrame(iFrameNum) : iFps += 1
wend