'World of Palma; Exploration demo
'5/12/2021
'Collision checking OFF version
'Cobalt
Encounter_Group
AS _BYTE 'what types of creature encounters possible Is_Cave
AS _BYTE 'Covers all Cave-like locations Display_Layer
AS _BYTE 'for tiles that the player can walk under Is_NPC_Location
AS _BYTE 'where the NPCs stand Is_Building
AS _BYTE 'covers shops and houses Start_X
AS INTEGER 'When entering a town player start here Exit_X
AS INTEGER 'When leaving a town player starts in world here
DIM SHARED Map
(128, 96) AS WorldTiles
, TownMap
(9, 50, 39) AS TownTiles
, P
AS PlayerTemp
DIM SHARED AnimationOrder
(3, 8) '8 frames for sync between Waves\marsh and Shore animations 'time for the layer system
MFI_Loader "PS_Overworld_Test.MFI"
'place the conveyor system in corect world location
CONST Conveyor_1_Pos_X
= 32 * 82 CONST Conveyor_1_Pos_Y
= 32 * 53 + 8 CONST Conveyor_2_Pos_X
= 32 * 79 + 8 CONST Conveyor_2_Pos_Y
= 32 * 56 CONST Conveyor_Frame_Speed
= 2 '--------------------------------------------------
DATA 0,1,2,3,4,4,1,0:
'shore animation order READ AnimationOrder
(1, i%%
) DATA 0,1,2,1:
'animation frame order READ Enter
(1).X
, Enter
(1).Y
, Enter
(1).Map
READ Exits
(1).X
, Exits
(1).Y
, Exits
(1).Map
'Enter Camineet from over world
Map(82, 46).Is_Village = 1
Map(83, 46).Is_Village = 1
Map(82, 47).Is_Village = 1
Map(83, 47).Is_Village = 1
'------------------------------
'Exit Camineet to over world
TownMap(0, 39, 18).Is_Exit = 1
TownMap(0, 38, 18).Is_Exit = 1
TownMap(0, 21, 27).Is_Exit = 1
TownMap(0, 20, 27).Is_Exit = 1
'Exit Camineet to Space port(if player has roadpass
TownMap(0, 11, 19).Is_Exit = 2
TownMap(0, 11, 20).Is_Exit = 2
'------------------------------
CONST Default_Key_Right
= 19712, Default_Key_Left
= 19200, Default_Key_Up
= 18432, Default_Key_Down
= 20480 CONST Default_A_Button
= 32, Default_B_Button
= 13, Default_Start_Button
= 65, Default_Select_Button
= 66 CONST down
= 0, up
= 1, right
= 2, left
= 3
'TIMER(T2!) ON
P.Wx = Exits(1).X
P.Wy = Exits(1).Y
P.Is_Intown = -1
IF CheckFlag%%
THEN Location_Checker P.Is_Intown
, P.Wx
, P.Wy: CheckFlag%%
= FALSE
TownMap_Tile_loader P.Wx, P.Wy, P.Tx, P.Ty 'Mapx%, Mapy%, Playrx%, Playry%
_PRINTSTRING (640, 45), "ID-" + STR$(TownMap
(P.Is_Intown
, P.Wx
, P.Wy
).Id
), Layer
(0) _PRINTSTRING (640, 60), "UP-" + STR$(TownMap
(P.Is_Intown
, P.Wx
, P.Wy
- 1).Id
) + " ", Layer
(0) _PRINTSTRING (640, 75), "DN-" + STR$(TownMap
(P.Is_Intown
, P.Wx
, P.Wy
+ 1).Id
) + " ", Layer
(0) _PRINTSTRING (640, 90), "LT-" + STR$(TownMap
(P.Is_Intown
, P.Wx
- 1, P.Wy
).Id
) + " ", Layer
(0) _PRINTSTRING (640, 105), "RT-" + STR$(TownMap
(P.Is_Intown
, P.Wx
+ 1, P.Wy
).Id
) + " ", Layer
(0) _PRINTSTRING (640, 120), "XT-" + STR$(TownMap
(P.Is_Intown
, P.Wx
+ 1, P.Wy
).Is_Exit
) + " ", Layer
(0) Map_Loader_tiled_Base P.Wx, P.Wy, P.Tx, P.Ty 'Mapx%, Mapy%, Playrx%, Playry%
Place_Alis
frame% = frame% + 1
'-----------------Controls------------------
IF Collision
(P.Wx
, P.Wy
- 1) THEN g.moving
= FALSE
IF Collision
(P.Wx
, P.Wy
+ 1) THEN g.moving
= FALSE
IF Collision
(P.Wx
- 1, P.Wy
) THEN g.moving
= FALSE
IF Collision
(P.Wx
+ 1, P.Wy
) THEN g.moving
= FALSE
'--------------------------------------------
'----------------Movement--------------------
P.Ty = P.Ty + 2
IF (ABS(P.Ty
) MOD 32) = 0 THEN g.moving
= FALSE: P.Wy
= P.Wy
- 1: P.Ty
= 0: CheckFlag%%
= TRUE
P.Ty = P.Ty - 2
IF (P.Ty
MOD 32) = 0 THEN g.moving
= FALSE: P.Wy
= P.Wy
+ 1: P.Ty
= 0: CheckFlag%%
= TRUE
P.Tx = P.Tx + 2
IF (ABS(P.Tx
) MOD 32) = 0 THEN g.moving
= FALSE: P.Wx
= P.Wx
- 1: P.Tx
= 0: CheckFlag%%
= TRUE
P.Tx = P.Tx - 2
IF (P.Tx
MOD 32) = 0 THEN g.moving
= FALSE: P.Wx
= P.Wx
+ 1: P.Tx
= 0: CheckFlag%%
= TRUE
IF g.moving
THEN Ft%%
= Ft%%
+ 1 IF Ft%%
= 8 THEN P.Fr
= P.Fr
+ 1: Ft%%
= 0 'Correct for map wrap
'--------------------
Result%% = TRUE 'always assume collision
IF TownMap
(P.Is_Intown
, X1%
, Y1%
).Is_Walkable
THEN Result%%
= FALSE
IF Map
(X1%
, Y1%
).Is_Walkable
THEN Result%%
= FALSE
Collision = Result%%
SUB Map_Loader_tiled_Base
(X1%
, Y1%
, Sx%
, Sy%
) mx% = X1% + x% - 9 '-9 to center on player character
my% = Y1% + y% - 7 '-7 to center(ish) on player character
'------Adjust for map wrap around------
IF mx%
< 0 THEN mx%
= 128 + mx%
'use addition cause mx% is a negative IF mx%
> 127 THEN mx%
= mx%
- 128 IF my%
< 0 THEN my%
= 96 + my%
'use addition cause my% is a negative IF my%
> 95 THEN my%
= my%
- 96 '--------------------------------------
'main map tiles
_PUTIMAGE (Sx%
+ x%
* 32, Sy%
+ y%
* 32)-STEP(31, 31), TileX2&
, Layer
(Map
(mx%
, my%
).Display_Layer
), (0 + Map
(mx%
, my%
).Id
* 34, 0)-STEP(31, 31) 'animated map tiles
IF Map
(mx%
, my%
).Is_Animated
THEN _PUTIMAGE (Sx%
+ x%
* 32, Sy%
+ y%
* 32)-STEP(31, 31), MapAni&
, Layer
(1), (544 + MainFrame
(1) * 34, 0)-STEP(31, 31) _PUTIMAGE (Sx%
+ x%
* 32, Sy%
+ y%
* 32)-STEP(31, 31), MapAni&
, Layer
(1), (544 + (Map
(mx%
, my%
).Id
- 21) * 34, 34 + MainFrame
(1) * 34)-STEP(31, 31) _PUTIMAGE (Sx%
+ x%
* 32, Sy%
+ y%
* 32)-STEP(31, 31), MapAni&
, Layer
(1), ((Map
(mx%
, my%
).Id
- 5) * 34, AnimationOrder
(1, MainFrame
(2)) * 34)-STEP(31, 31) 'Horizontal conveyor
_PUTIMAGE (Sx%
+ Conveyor_1_Pos_X
- (X1%
* 32), Sy%
+ Conveyor_1_Pos_Y
- (Y1%
* 32)), Conv&
, Layer
(2), (0, 0 + (MainFrame
(0) * 34))-STEP(255, 31) 'vertical conveyor
_PUTIMAGE (Sx%
+ Conveyor_2_Pos_X
- (X1%
* 32), Sy%
+ Conveyor_2_Pos_Y
- (Y1%
* 32)), Conv&
, Layer
(2), (257 + (MainFrame
(0) * 34), 0)-STEP(31, 223) SubFrame(i%%) = SubFrame(i%%) + 1
IF SubFrame
(0) = 5 + Conveyor_Frame_Speed
THEN MainFrame
(0) = MainFrame
(0) + Conveyor_Frame_Speed: SubFrame
(0) = 0 IF SubFrame
(1) = 16 THEN MainFrame
(1) = MainFrame
(1) + 1: SubFrame
(1) = 0 IF SubFrame
(2) = 24 THEN MainFrame
(2) = MainFrame
(2) + 1: SubFrame
(2) = 0 IF MainFrame
(0) = 8 THEN MainFrame
(0) = 0 IF MainFrame
(1) = 4 THEN MainFrame
(1) = 0 IF MainFrame
(2) = 8 THEN MainFrame
(2) = 0
SUB TownMap_Tile_loader
(X1%
, Y1%
, Sx%
, Sy%
) mx% = X1% + x% - 9 '-9 to center on player character
my% = Y1% + y% - 7 '-7 to center(ish) on player character
'town map tiles
_PUTIMAGE (Sx%
+ x%
* 32, Sy%
+ y%
* 32)-STEP(31, 31), Layer
(3), Layer
(1), (0 + TownMap
(P.Is_Intown
, mx%
, my%
).Id
* 34, 0)-STEP(31, 31)
' STATIC LastCount%
FPSC% = frame%
frame% = 0
_PUTIMAGE (290, 210)-STEP(31, 45), char&
, Layer
(1), (0 + 17 * g.facing
, 120)-STEP(15, 22) _PUTIMAGE (290, 210)-STEP(31, 45), char&
, Layer
(1), (68 + 51 * g.facing
+ AlisAnim
(P.Fr
) * 17, 120)-STEP(15, 22)
SUB Location_Checker
(Map%%
, X%
, Y%
)
IF TownMap
(Map%%
, X%
, Y%
).Is_Exit
THEN P.Is_Intown = Exits(TownMap(Map%%, X%, Y%).Is_Exit).Map
P.Wx = Exits(TownMap(Map%%, X%, Y%).Is_Exit).X
P.Wy = Exits(TownMap(Map%%, X%, Y%).Is_Exit).Y
IF Map
(X%
, Y%
).Is_Village
THEN P.Is_Intown = Enter(Map(X%, Y%).Is_Village).Map
P.Wx = Enter(Map(X%, Y%).Is_Village).X
P.Wy = Enter(Map(X%, Y%).Is_Village).Y
GET #1, , c~%%
'retrieve number of files FOffset&(I~%%) = FOffset&(I~%%) + 1
TileX2& = LoadGFX(FOffset(1), Size(1)) ' _LOADIMAGE("gfx\maps\PalmaTiles2x2.bmp", 32) '_NEWIMAGE(640, 480, 32)
Conv& = LoadGFX(FOffset(2), Size(2)) '_LOADIMAGE("gfx\maps\conveyoranim.bmp", 32) 'Conveyor
MapAni& = LoadGFX(FOffset(3), Size(3)) '_LOADIMAGE("gfx\maps\mapanimation.bmp", 32) 'Water, shore, and marsh frames
char& = LoadGFX(FOffset(4), Size(4)) '_LOADIMAGE("gfx\CharacterSheetC.png", 32) '
Layer(3) = LoadGFX(FOffset(6), Size(6))
LoadData FOffset(5), Size(5)
LoadData FOffset(7), Size(7)
SUB LoadData
(Foff&
, Size&
)
REM '$include:'MFI_Loader2.bi'
FUNCTION LoadFFX&
(Foff&
, Size&
, Fize%%
) LoadFFX&
= _LOADFONT("temp.dat", Fize%%
, "monospace")