Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need some help getting characters to follow each other correctly
#1
I'm having some difficulty in getting the second character to move in the last direction traveled. It does keep some of the offset but it follows the main characters current movement instead of the last move, then jumps behind the character. which is an issue if you move the character back and forth cause then the second character should be under the first but instead shows up behind.
The routines that deal with the movement are "Move_Team" and "Place_Team" the finer movement is done within the Main loop in the "Movement" section.

If you want to try it do not forget the MFI file attached and the arrow keys move the character.

Code: (Select All)
TYPE Character_data
Xloc AS _BYTE
Yloc AS _BYTE
PixX AS SINGLE
PixY AS SINGLE
Dirc AS _BYTE
END TYPE

TYPE Player_data
HP AS _UNSIGNED _BYTE
MP AS _BYTE
HP_Max AS _UNSIGNED _BYTE
MP_Max AS _UNSIGNED _BYTE
Wep AS _BYTE
Arm AS _BYTE
Shd AS _BYTE
Xp AS _UNSIGNED INTEGER
Lvl AS _BYTE
PwrUP AS _BYTE
Alive AS _BYTE
AttPwr AS _UNSIGNED _BYTE
DefPwr AS _UNSIGNED _BYTE
CD AS Character_data
END TYPE

TYPE MapData
ID AS INTEGER
END TYPE

TYPE GameData
WorldXSize AS INTEGER
WorldYSize AS INTEGER
WaterFrame AS _BYTE
ShoreFrame AS _BYTE
ConveFrame AS _BYTE
LavaFrame AS _BYTE
Moving AS _BYTE
Noah AS _BYTE
Odin AS _BYTE
Myau AS _BYTE
END TYPE

REM '$include:'controls.bi'
TYPE ControllerKeys
KBCon_Up AS LONG
KBCon_Down AS LONG
KBCon_Left AS LONG
KBCon_Right AS LONG
KBCon_Select AS LONG
KBCon_Start AS LONG
KBCon_A_Button AS LONG
KBCon_B_Button AS LONG

Control_Pad AS _BYTE 'which Gamepad\Joystick Device Is player Using?
BAD_Pad AS _BYTE 'option for Buttons As Directions
Joy_Up AS _BYTE 'axis for up
Joy_Up_Val AS _BYTE 'axis value for up
Joy_Down AS _BYTE 'axis for down
Joy_Down_Val AS _BYTE 'axis value for down
Joy_Left AS _BYTE 'axis for left
Joy_Left_Val AS _BYTE 'axis value for left
Joy_Right AS _BYTE 'axis for right
Joy_Right_Val AS _BYTE 'axis value for right
Joy_Select AS _BYTE
Joy_Start AS _BYTE
Joy_A_Button AS _BYTE
Joy_B_Button AS _BYTE
Joy_Button_Up AS _BYTE 'for people whos controllers give BUTTON states for direction keys
Joy_Button_Down AS _BYTE 'or just want to use buttons for the direction keys.
Joy_Button_Left AS _BYTE '""""
Joy_Button_Right AS _BYTE 'however this fails to work so may not be implemented.
END TYPE

' DIM SHARED KeyCodes(134) AS KeyCodeData, DeviceData(16) AS DEVICE_Info
DIM SHARED C AS ControllerKeys

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 ESC_Key = 27, ESC = 99
CONST TRUE = -1, FALSE = NOT TRUE
CONST DOWN = 0, LEFT = 3, UP = 1, RIGHT = 2, SELECT_BUTTON = 4, START_BUTTON = 5, BUTTON_B = 6, BUTTON_A = 7

DIM SHARED F1

MFI_Loader "P_Star_I.MFI"
'OPEN "PalmaWorldBase.txt" FOR BINARY AS #1
'GET #1, , MapTileHeight
'GET #1, , MapTileWidth
GET #F1, , MapTileHeight
GET #F1, , MapTileWidth

DIM SHARED Map(MapTileWidth, MapTileHeight) AS MapData
GET #F1, , Map()
CLOSE
IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"

DIM SHARED Layer(16) AS LONG, G AS GameData
DIM SHARED P(4) AS Player_data
DIM SHARED Animation(4, 6) AS _BYTE
Animation(0, 0) = 0: Animation(0, 1) = 1: Animation(0, 2) = 2: Animation(0, 3) = 3
Animation(1, 0) = 0: Animation(1, 1) = 1: Animation(1, 2) = 2: Animation(1, 3) = 3: Animation(1, 4) = 4: Animation(1, 5) = 4: Animation(1, 6) = 1
Animation(2, 0) = 0: Animation(2, 1) = 1: Animation(2, 2) = 2: Animation(2, 3) = 1
Animation(3, 0) = 0: Animation(3, 1) = 1: Animation(3, 2) = 2: Animation(3, 3) = 0

SCREEN _NEWIMAGE(800, 600, 32)
Layer(0) = _DISPLAY
Layer(1) = _COPYIMAGE(_DISPLAY)
Layer(2) = _NEWIMAGE(2048, 1532, 32)
'Layer(3) = _LOADIMAGE("pstartile_16x16_Game.bmp", 32)
'Layer(4) = _LOADIMAGE("TileMaster.bmp", 32)
'Layer(5) = _LOADIMAGE("CharacterSheet_Master.bmp", 32)
_CLEARCOLOR _RGB32(0), Layer(2)
_CLEARCOLOR _RGB32(62), Layer(5)

'-----------------Palma Structures-----------------
PalmaMaps:
DATA 22
'Towns data
DATA 81,45,3,3,0: 'Camineet
DATA 69,56,3,3,0: 'Parolit
DATA 68,44,4,4,1: 'Star Port
DATA 13,15,0,0,2: 'Abion
DATA 66,29,0,0,2: 'Loar
DATA 23,49,0,0,3: 'Bortevo
DATA 53,55,0,0,2: 'Gothic
DATA 84,77,0,0,2: 'Eppi
DATA 102,44,-1,0,0: 'Scion
DATA 117,78,-2,0,0: 'Drasgow
'Cave Data
DATA 97,10,0,0,4: 'Naula cave
DATA 113,7,0,0,4: 'Baya Malay Cave B
DATA 119,13,0,0,4: 'Baya Malay Cave A
DATA 21,36,0,0,4: 'Bortevo Passage B
DATA 24,46,0,0,4: 'Bortevo Passage A
DATA 117,55,0,0,4: 'Scion Cave
DATA 77,64,0,0,4: 'Medusa's Cave
'Tower data
DATA 103,19,0,0,5: 'Baya Malay Tower
DATA 103,33,0,0,5: 'Baya Malay Prison
DATA 5,42,0,0,5: 'Forgotten tower

'DATA 31,77,0,0,5: 'Medusa's tower
DATA 49,81,0,0,6: 'Prison
'---------------------------------------------------
P(0).Alive = TRUE
P(1).Alive = TRUE
G.Myau = TRUE

ShiftX% = 64
ShiftY% = 36
'draw map screen
DO
'moving the characters
IF _KEYDOWN(Default_Key_Up) AND (NOT G.Moving) THEN P(0).CD.Dirc = UP: G.Moving = TRUE
IF _KEYDOWN(Default_Key_Left) AND (NOT G.Moving) THEN P(0).CD.Dirc = LEFT: G.Moving = TRUE
IF _KEYDOWN(Default_Key_Right) AND (NOT G.Moving) THEN P(0).CD.Dirc = RIGHT: G.Moving = TRUE
IF _KEYDOWN(Default_Key_Down) AND (NOT G.Moving) THEN P(0).CD.Dirc = DOWN: G.Moving = TRUE
IF _KEYDOWN(27) THEN exitflag%% = -1
SELECT CASE P(0).CD.Dirc
  CASE UP
  'IF Collision(P(0).Wx, P(0).Wy - 1) THEN G.Moving = FALSE
  CASE DOWN
  'IF Collision(P(0).Wx, P(0).Wy + 1) THEN G.Moving = FALSE
  CASE LEFT
  'IF Collision(P(0).Wx - 1, P(0).Wy) THEN G.Moving = FALSE
  CASE RIGHT
  'IF Collision(P(0).Wx + 1, P(0).Wy) THEN G.Moving = FALSE
END SELECT
'--------------------------------------------
'--------------------------------Movement----------------------------
IF G.Moving THEN
  SELECT CASE P(0).CD.Dirc
  CASE DOWN
    P(0).CD.PixY = P(0).CD.PixY + 2
    IF (ABS(P(0).CD.PixY) MOD 32) = 0 THEN G.Moving = FALSE: P(0).CD.PixY = 0: Move_Team
    IF NOT _KEYDOWN(Default_Key_Down) THEN Ft%% = 0: AFrame%% = 0 ELSE G.Moving = TRUE
  CASE UP
    P(0).CD.PixY = P(0).CD.PixY - 2
    IF (ABS(P(0).CD.PixY) MOD 32) = 0 THEN G.Moving = FALSE: P(0).CD.PixY = 0: Move_Team
    IF NOT _KEYDOWN(Default_Key_Up) THEN Ft%% = 0: AFrame%% = 0 ELSE G.Moving = TRUE
  CASE LEFT
    P(0).CD.PixX = P(0).CD.PixX - 2
    IF (ABS(P(0).CD.PixX) MOD 32) = 0 THEN G.Moving = FALSE: P(0).CD.PixX = 0: Move_Team
    IF NOT _KEYDOWN(Default_Key_Left) THEN Ft%% = 0: AFrame%% = 0 ELSE G.Moving = TRUE
  CASE RIGHT
    P(0).CD.PixX = P(0).CD.PixX + 2
    IF (ABS(P(0).CD.PixX) MOD 32) = 0 THEN G.Moving = FALSE: P(0).CD.PixX = 0: Move_Team
    IF NOT _KEYDOWN(Default_Key_Right) THEN Ft%% = 0: AFrame%% = 0 ELSE G.Moving = TRUE
  END SELECT
END IF
'======================================================================
IF G.Moving THEN Ft%% = Ft%% + 1
IF Ft%% = 8 THEN AFrame%% = AFrame%% + 1: Ft%% = 0
IF AFrame%% = 4 THEN AFrame%% = 0
IF P(0).CD.Xloc < 0 THEN: PRINT "ERROR LOCATION": END
Draw_Map_Area P(0).CD.Xloc, P(0).CD.Yloc
Place_Team AFrame%%
Place_Alis AFrame%%
_PUTIMAGE , Layer(1), Layer(0)
_LIMIT 60
LOOP UNTIL INKEY$ = CHR$(27)






SUB Draw_Map_Area (ShiftX%, ShiftY%)
STATIC Fc%
FOR Y%% = 0 TO 15
  IF ShiftY% + Y%% > 92 THEN BlockY%% = ShiftY% + Y%% - 93 ELSE BlockY%% = ShiftY% + Y%%
  _PRINTSTRING (768, 32 * Y%%), STR$(BlockY%%) + "  ", Layer(1)

  FOR X%% = 0 TO 23
  'World Scroll Clamps

  IF ShiftX% + X%% > 127 THEN BlockX%% = ShiftX% + X%% - 128 ELSE BlockX%% = ShiftX% + X%%

  _PRINTSTRING (0 + 32 * X%%, 516), STR$(BlockX%%) + "  ", Layer(1)
  '  _PRINTSTRING (0, 550), STR$(BlockX%%) + STR$(BlockY%%)

  SELECT CASE Map(BlockX%%, BlockY%%).ID
    CASE 1 TO 4
    IF G.WaterFrame >= 4 OR G.WaterFrame < 0 THEN G.WaterFrame = 0
    A%% = Animation(0, G.WaterFrame)
    CASE 5 TO 20
    IF G.ShoreFrame >= 7 OR G.ShoreFrame < 0 THEN G.ShoreFrame = 0
    A%% = Animation(1, G.ShoreFrame)
    CASE 45 TO 49
    IF G.LavaFrame >= 4 OR G.LavaFrame < 0 THEN G.LavaFrame = 0
    A%% = Animation(2, G.LavaFrame)
    CASE 139 TO 154
    IF G.ConveFrame >= 4 OR G.ConveFrame < 0 THEN G.ConveFrame = 0
    A%% = Animation(0, G.ConveFrame)
    CASE ELSE
    A%% = 0
  END SELECT
  _PUTIMAGE (32 * X%% - P(0).CD.PixX, 32 * Y%% - P(0).CD.PixY)-STEP(31, 31), Layer(3), Layer(1), (17 * Map(BlockX%%, BlockY%%).ID, 17 * A%%)-STEP(15, 15)
  NEXT X%%
NEXT Y%%

Fc% = Fc% + 1
IF Fc% = 40 THEN Fc% = 0: G.WaterFrame = G.WaterFrame + 1: G.ShoreFrame = G.ShoreFrame + 1: G.LavaFrame = G.LavaFrame + 1
IF Fc% MOD 8 = 0 THEN G.ConveFrame = G.ConveFrame + 1
END SUB

SUB Move_Team
'Move Followers, move all even if some are not present\dead
FOR i%% = 3 TO 1 STEP -1
  P(i%%).CD.Xloc = P(i%% - 1).CD.Xloc
  P(i%%).CD.Yloc = P(i%% - 1).CD.Yloc
  P(i%%).CD.Dirc = P(i%% - 1).CD.Dirc
NEXT
'now move Alis
SELECT CASE P(0).CD.Dirc
  CASE UP
  P(0).CD.Yloc = P(0).CD.Yloc - 1
  CASE DOWN
  P(0).CD.Yloc = P(0).CD.Yloc + 1
  CASE LEFT
  P(0).CD.Xloc = P(0).CD.Xloc - 1
  CASE RIGHT
  P(0).CD.Xloc = P(0).CD.Xloc + 1
END SELECT
'Clamp Values for map scrolling
IF P(0).CD.Yloc = 93 THEN P(0).CD.Yloc = 0
IF P(0).CD.Yloc = -1 THEN P(0).CD.Yloc = 92
IF P(0).CD.Xloc = -128 THEN P(0).CD.Xloc = 0
IF P(0).CD.Xloc = -1 THEN P(0).CD.Xloc = 127
END SUB


SUB Place_Alis (Frame%%)
IF NOT G.Moving THEN
  _PUTIMAGE (290, 210)-STEP(31, 45), Layer(5), Layer(1), (0 + 17 * P(0).CD.Dirc, 108)-STEP(15, 22)
ELSE
  _PUTIMAGE (290, 210)-STEP(31, 45), Layer(5), Layer(1), (68 + 51 * P(0).CD.Dirc + Animation(2, Frame%%) * 17, 108)-STEP(15, 22)
END IF
END SUB


SUB Place_Team (Frame%%)
IF P(0).Alive THEN t%% = 0 ELSE t%% = -1
IF NOT G.Moving THEN
  IF G.Noah AND P(3).Alive THEN
  t%% = t%% + 1
  _PUTIMAGE (290, 210)-STEP(31, 47), Layer(5), Layer(1), (0 + 17 * P(3).CD.Dirc, 181)-STEP(15, 23)
  END IF
  IF G.Odin AND P(2).Alive THEN
  t%% = t%% + 1
  _PUTIMAGE (290, 210)-STEP(31, 47), Layer(5), Layer(1), (0 + 17 * P(2).CD.Dirc, 156)-STEP(15, 23)
  END IF
  IF G.Myau AND P(1).Alive THEN
  t%% = t%% + 1
  _PUTIMAGE (290 - 32 * (P(0).CD.Xloc - P(1).CD.Xloc) - P(1).CD.PixX, 210 - 32 * (P(0).CD.Yloc - P(1).CD.Yloc) - P(1).CD.PixY)-STEP(31, 45), Layer(5), Layer(1), (0 + 17 * P(1).CD.Dirc, 132)-STEP(15, 22)
  END IF

ELSE
  'Just you Myau until things work right.
  _PUTIMAGE (290 - 32 * (P(0).CD.Xloc - P(1).CD.Xloc) - P(1).CD.PixX, 210 - 32 * (P(0).CD.Yloc - P(1).CD.Yloc) - P(1).CD.PixY)-STEP(31, 45), Layer(5), Layer(1), (68 + 51 * P(1).CD.Dirc + Animation(3, Frame%%) * 17, 132)-STEP(15, 22)
END IF
END SUB



SUB ClearLayer (L&)
old& = _DEST
_DEST L&
CLS ' ,0
_DEST old&
END SUB

SUB ClearLayerTrans (L&)
old& = _DEST
_DEST L&
CLS , 0
_DEST old&
END SUB

SUB MFI_Loader (FN$)
DIM Size(128) AS LONG, FOffset(128) AS LONG
OPEN FN$ FOR BINARY AS #1
GET #1, , c~%% 'retrieve number of files
FOR I~%% = 1 TO c~%%
  GET #1, , FOffset(I~%%)
  GET #1, , Size(I~%%)
  FOffset&(I~%%) = FOffset&(I~%%) + 1
NEXT I~%%

Layer(3) = LoadGFX(FOffset(2), Size(2)) '
Layer(4) = LoadGFX(FOffset(3), Size(3)) '
Layer(5) = LoadGFX(FOffset(4), Size(4)) '
' Layer(3) = _LOADIMAGE("pstartile_16x16_Game.bmp", 32)
' Layer(4) = _LOADIMAGE("TileMaster.bmp", 32)
' Layer(5) = _LOADIMAGE("CharacterSheet_Master.bmp", 32)


LoadData FOffset(1), Size(1)
F1 = FREEFILE
OPEN "temp.dat" FOR BINARY AS #F1

' CLOSE #1
' IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
END SUB

SUB LoadData (Foff&, Size&)
IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
OPEN "temp.dat" FOR BINARY AS #3
dat$ = SPACE$(Size&)
GET #1, Foff&, dat$
PUT #3, , dat$
CLOSE #3
END SUB

REM '$include:'MFI_Loader2.bi'

FUNCTION LoadGFX& (Foff&, Size&)
IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
OPEN "temp.dat" FOR BINARY AS #3
dat$ = SPACE$(Size&)
GET #1, Foff&, dat$
PUT #3, , dat$
CLOSE #3
LoadGFX& = _LOADIMAGE("temp.dat", 32)
END FUNCTION


Attached Files
.mfi   P_Star_I.MFI (Size: 3.03 MB / Downloads: 8)
Reply
#2
Replace  "Place_Team" with this

Code: (Select All)
SUB Place_Team (Frame%%)
IF P(0).Alive THEN t%% = 0 ELSE t%% = -1
IF NOT G.Moving THEN
  IF G.Noah AND P(3).Alive THEN
  t%% = t%% + 1
  _PUTIMAGE (290 - 32 * (P(0).CD.Xloc - P(3).CD.Xloc) + P(3).CD.PixX, 210 - 32 * (P(0).CD.Yloc - P(3).CD.Yloc) + P(3).CD.PixY)-STEP(31, 47), Layer(5), Layer(1), (0 + 17 * P(3).CD.Dirc, 181)-STEP(15, 23)
  END IF
  IF G.Odin AND P(2).Alive THEN
  t%% = t%% + 1
  _PUTIMAGE (290 - 32 * (P(0).CD.Xloc - P(2).CD.Xloc) + P(2).CD.PixX, 210 - 32 * (P(0).CD.Yloc - P(2).CD.Yloc) + P(2).CD.PixY)-STEP(31, 47), Layer(5), Layer(1), (0 + 17 * P(2).CD.Dirc, 156)-STEP(15, 23)
  END IF
  IF G.Myau AND P(1).Alive THEN
  t%% = t%% + 1
  _PUTIMAGE (290 - 32 * (P(0).CD.Xloc - P(1).CD.Xloc) - P(1).CD.PixX, 210 - 32 * (P(0).CD.Yloc - P(1).CD.Yloc) - P(1).CD.PixY)-STEP(31, 45), Layer(5), Layer(1), (0 + 17 * P(1).CD.Dirc, 132)-STEP(15, 22)
  END IF

ELSE
  _PUTIMAGE (290 - 32 * (P(0).CD.Xloc - P(3).CD.Xloc) + P(3).CD.PixX, 210 - 32 * (P(0).CD.Yloc - P(3).CD.Yloc) + P(3).CD.PixY)-STEP(31, 45), Layer(5), Layer(1), (68 + 51 * P(3).CD.Dirc + Animation(2, Frame%%) * 17, 181)-STEP(15, 22)
  _PUTIMAGE (290 - 32 * (P(0).CD.Xloc - P(2).CD.Xloc) + P(2).CD.PixX, 210 - 32 * (P(0).CD.Yloc - P(2).CD.Yloc) + P(2).CD.PixY)-STEP(31, 45), Layer(5), Layer(1), (68 + 51 * P(2).CD.Dirc + Animation(2, Frame%%) * 17, 156)-STEP(15, 22)
  'Just you Myau until things work right.
  _PUTIMAGE (290 - 32 * (P(0).CD.Xloc - P(1).CD.Xloc) + P(1).CD.PixX, 210 - 32 * (P(0).CD.Yloc - P(1).CD.Yloc) + P(1).CD.PixY)-STEP(31, 45), Layer(5), Layer(1), (68 + 51 * P(1).CD.Dirc + Animation(3, Frame%%) * 17, 132)-STEP(15, 22)
END IF
END SUB

and this section of code
Code: (Select All)
P(0).Alive = TRUE
P(1).Alive = TRUE
G.Myau = TRUE

with
Code: (Select All)
P(0).Alive = TRUE
P(1).Alive = TRUE
P(2).Alive = TRUE
P(3).Alive = TRUE
G.Myau = TRUE
G.Odin = TRUE
G.Noah = TRUE

and it will show the "jumpy" movement better.
Reply
#3
In the original version (first from the top), I found out that line 302 does it. The frame synchronization is done by Move_Team. I think that on line 302, the target location will be somehow wrong. It doesn't distinguish where the movement is going and places the frame the same way as line 297 - but line 297 it is used in case the characters are always going in the same direction, if I understand it correctly.
I don't know how you could sharpen 4 directions of movement with a single mathematical determination of the frame in the source image at the end of the _PutImage command on line 302.


Reply
#4
(11-21-2024, 06:15 PM)Petr Wrote: In the original version (first from the top), I found out that line 302 does it. The frame synchronization is done by Move_Team. I think that on line 302, the target location will be somehow wrong. It doesn't distinguish where the movement is going and places the frame the same way as line 297 - but line 297 it is used in case the characters are always going in the same direction, if I understand it correctly.
I don't know how you could sharpen 4 directions of movement with a single mathematical determination of the frame in the source image at the end of the _PutImage command on line 302.

I think there is something being lost in translation. "sharpen 4 directions" ?

the line numbers do not match as well, 302 for me is an END SUB.
I am guessing that the line numbers are supposed to be for the _PUTIMAGE lines.
if that is the case, the first _PUTIMAGE (your line 297 I believe) is for a stationary tile, when they are not moving. (NOT G.Moving)
the second _PUTIMAGE is for the moving animation (line 302)
Direction is determined by p().CD.Dirc which is set when the player presses an arrow key and propagated to the other characters with the Move_Team sub.

I think I have to have the following characters move with the map to help fix the jump, because the main character stays in place and the map moves around her. Which I think is what is happening to the following characters, the map is moving around them and they need to be moving more with the map.
I just have not figured out how to do that yet.
Reply
#5
I don't understand this. Why do you use .PixX and .PixY in the main loop to move the map and then, in MoveTeam, you suddenly start working with .Xloc and .Yloc on the map (and this is also copied to the character movement above). This is strange to me. I thought that the map movement would be determined by PixX and PixY from the main loop? Or am I completely wrong?

Its just counter to 32 by 2 for map move...


Reply
#6
I'm sorry, but your program has confused me so completely that I don't even know who I am anymore.


Reply
#7
Well I have it closer, but still have an issue with the following characters being too far back and jumping forward. but at least their path is correct, I can fix the jumping forward but then their path is wrong, it is one way or the other for some reason.


Code: (Select All)
TYPE Character_data
Xloc AS _BYTE
Yloc AS _BYTE
PixX AS SINGLE
PixY AS SINGLE
Dirc AS _BYTE
END TYPE

TYPE Player_data
HP AS _UNSIGNED _BYTE
MP AS _BYTE
HP_Max AS _UNSIGNED _BYTE
MP_Max AS _UNSIGNED _BYTE
Wep AS _BYTE
Arm AS _BYTE
Shd AS _BYTE
Xp AS _UNSIGNED INTEGER
Lvl AS _BYTE
PwrUP AS _BYTE
Alive AS _BYTE
AttPwr AS _UNSIGNED _BYTE
DefPwr AS _UNSIGNED _BYTE
CD AS Character_data
END TYPE

TYPE MapData
ID AS INTEGER
END TYPE

TYPE GameData
WorldXSize AS INTEGER
WorldYSize AS INTEGER
WaterFrame AS _BYTE
ShoreFrame AS _BYTE
ConveFrame AS _BYTE
LavaFrame AS _BYTE
Moving AS _BYTE
Noah AS _BYTE
Odin AS _BYTE
Myau AS _BYTE
END TYPE

REM '$include:'controls.bi'
TYPE ControllerKeys
KBCon_Up AS LONG
KBCon_Down AS LONG
KBCon_Left AS LONG
KBCon_Right AS LONG
KBCon_Select AS LONG
KBCon_Start AS LONG
KBCon_A_Button AS LONG
KBCon_B_Button AS LONG

Control_Pad AS _BYTE 'which Gamepad\Joystick Device Is player Using?
BAD_Pad AS _BYTE 'option for Buttons As Directions
Joy_Up AS _BYTE 'axis for up
Joy_Up_Val AS _BYTE 'axis value for up
Joy_Down AS _BYTE 'axis for down
Joy_Down_Val AS _BYTE 'axis value for down
Joy_Left AS _BYTE 'axis for left
Joy_Left_Val AS _BYTE 'axis value for left
Joy_Right AS _BYTE 'axis for right
Joy_Right_Val AS _BYTE 'axis value for right
Joy_Select AS _BYTE
Joy_Start AS _BYTE
Joy_A_Button AS _BYTE
Joy_B_Button AS _BYTE
Joy_Button_Up AS _BYTE 'for people whos controllers give BUTTON states for direction keys
Joy_Button_Down AS _BYTE 'or just want to use buttons for the direction keys.
Joy_Button_Left AS _BYTE '""""
Joy_Button_Right AS _BYTE 'however this fails to work so may not be implemented.
END TYPE

' DIM SHARED KeyCodes(134) AS KeyCodeData, DeviceData(16) AS DEVICE_Info
DIM SHARED C AS ControllerKeys

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 ESC_Key = 27, ESC = 99
CONST TRUE = -1, FALSE = NOT TRUE
CONST DOWN = 0, LEFT = 3, UP = 1, RIGHT = 2, SELECT_BUTTON = 4, START_BUTTON = 5, BUTTON_B = 6, BUTTON_A = 7

DIM SHARED F1

MFI_Loader "P_Star_I.MFI"
'OPEN "PalmaWorldBase.txt" FOR BINARY AS #1
'GET #1, , MapTileHeight
'GET #1, , MapTileWidth
GET #F1, , MapTileHeight
GET #F1, , MapTileWidth

DIM SHARED Map(MapTileWidth, MapTileHeight) AS MapData
GET #F1, , Map()
CLOSE
IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"

DIM SHARED Layer(16) AS LONG, G AS GameData
DIM SHARED P(4) AS Player_data
DIM SHARED Animation(4, 6) AS _BYTE
Animation(0, 0) = 0: Animation(0, 1) = 1: Animation(0, 2) = 2: Animation(0, 3) = 3
Animation(1, 0) = 0: Animation(1, 1) = 1: Animation(1, 2) = 2: Animation(1, 3) = 3: Animation(1, 4) = 4: Animation(1, 5) = 4: Animation(1, 6) = 1
Animation(2, 0) = 0: Animation(2, 1) = 1: Animation(2, 2) = 2: Animation(2, 3) = 1
Animation(3, 0) = 0: Animation(3, 1) = 1: Animation(3, 2) = 2: Animation(3, 3) = 0

SCREEN _NEWIMAGE(800, 600, 32)
Layer(0) = _DISPLAY
Layer(1) = _COPYIMAGE(_DISPLAY)
Layer(2) = _NEWIMAGE(2048, 1532, 32)
'Layer(3) = _LOADIMAGE("pstartile_16x16_Game.bmp", 32)
'Layer(4) = _LOADIMAGE("TileMaster.bmp", 32)
'Layer(5) = _LOADIMAGE("CharacterSheet_Master.bmp", 32)
_CLEARCOLOR _RGB32(0), Layer(2)
_CLEARCOLOR _RGB32(62), Layer(5)

'-----------------Palma Structures-----------------
PalmaMaps:
DATA 22
'Towns data
DATA 81,45,3,3,0: 'Camineet
DATA 69,56,3,3,0: 'Parolit
DATA 68,44,4,4,1: 'Star Port
DATA 13,15,0,0,2: 'Abion
DATA 66,29,0,0,2: 'Loar
DATA 23,49,0,0,3: 'Bortevo
DATA 53,55,0,0,2: 'Gothic
DATA 84,77,0,0,2: 'Eppi
DATA 102,44,-1,0,0: 'Scion
DATA 117,78,-2,0,0: 'Drasgow
'Cave Data
DATA 97,10,0,0,4: 'Naula cave
DATA 113,7,0,0,4: 'Baya Malay Cave B
DATA 119,13,0,0,4: 'Baya Malay Cave A
DATA 21,36,0,0,4: 'Bortevo Passage B
DATA 24,46,0,0,4: 'Bortevo Passage A
DATA 117,55,0,0,4: 'Scion Cave
DATA 77,64,0,0,4: 'Medusa's Cave
'Tower data
DATA 103,19,0,0,5: 'Baya Malay Tower
DATA 103,33,0,0,5: 'Baya Malay Prison
DATA 5,42,0,0,5: 'Forgotten tower

'DATA 31,77,0,0,5: 'Medusa's tower
DATA 49,81,0,0,6: 'Prison
'---------------------------------------------------
P(0).Alive = TRUE
P(1).Alive = TRUE
P(2).Alive = TRUE
P(3).Alive = TRUE
G.Myau = TRUE
G.Odin = TRUE
G.Noah = TRUE

ShiftX% = 64
ShiftY% = 36
'draw map screen
DO
'moving the characters
IF _KEYDOWN(Default_Key_Up) AND (NOT G.Moving) THEN P(0).CD.Dirc = UP: G.Moving = TRUE
IF _KEYDOWN(Default_Key_Left) AND (NOT G.Moving) THEN P(0).CD.Dirc = LEFT: G.Moving = TRUE
IF _KEYDOWN(Default_Key_Right) AND (NOT G.Moving) THEN P(0).CD.Dirc = RIGHT: G.Moving = TRUE
IF _KEYDOWN(Default_Key_Down) AND (NOT G.Moving) THEN P(0).CD.Dirc = DOWN: G.Moving = TRUE
IF _KEYDOWN(27) THEN exitflag%% = -1
SELECT CASE P(0).CD.Dirc
  CASE UP
  'IF Collision(P(0).Wx, P(0).Wy - 1) THEN G.Moving = FALSE
  CASE DOWN
  'IF Collision(P(0).Wx, P(0).Wy + 1) THEN G.Moving = FALSE
  CASE LEFT
  'IF Collision(P(0).Wx - 1, P(0).Wy) THEN G.Moving = FALSE
  CASE RIGHT
  'IF Collision(P(0).Wx + 1, P(0).Wy) THEN G.Moving = FALSE
END SELECT
'--------------------------------------------
'----------------Movement--------------------
IF G.Moving THEN
  SELECT CASE P(0).CD.Dirc
  CASE DOWN
    P(0).CD.PixY = P(0).CD.PixY + 2
    IF (ABS(P(0).CD.PixY) MOD 32) = 0 THEN G.Moving = FALSE: P(0).CD.PixY = 0: Move_Team
    IF NOT _KEYDOWN(Default_Key_Down) THEN Ft%% = 0: AFrame%% = 0 ELSE G.Moving = TRUE
  CASE UP
    P(0).CD.PixY = P(0).CD.PixY - 2
    IF (ABS(P(0).CD.PixY) MOD 32) = 0 THEN G.Moving = FALSE: P(0).CD.PixY = 0: Move_Team
    IF NOT _KEYDOWN(Default_Key_Up) THEN Ft%% = 0: AFrame%% = 0 ELSE G.Moving = TRUE
  CASE LEFT
    P(0).CD.PixX = P(0).CD.PixX - 2
    IF (ABS(P(0).CD.PixX) MOD 32) = 0 THEN G.Moving = FALSE: P(0).CD.PixX = 0: Move_Team
    IF NOT _KEYDOWN(Default_Key_Left) THEN Ft%% = 0: AFrame%% = 0 ELSE G.Moving = TRUE
  CASE RIGHT
    P(0).CD.PixX = P(0).CD.PixX + 2
    IF (ABS(P(0).CD.PixX) MOD 32) = 0 THEN G.Moving = FALSE: P(0).CD.PixX = 0: Move_Team
    IF NOT _KEYDOWN(Default_Key_Right) THEN Ft%% = 0: AFrame%% = 0 ELSE G.Moving = TRUE
  END SELECT
  ' Walk_Team
END IF
IF G.Moving THEN Ft%% = Ft%% + 1
IF Ft%% = 8 THEN AFrame%% = AFrame%% + 1: Ft%% = 0
IF AFrame%% = 4 THEN AFrame%% = 0
IF P(0).CD.Xloc < 0 THEN: PRINT "ERROR LOCATION": END
Draw_Map_Area P(0).CD.Xloc, P(0).CD.Yloc
Place_Team AFrame%%
Place_Alis AFrame%%
_PUTIMAGE , Layer(1), Layer(0)
_LIMIT 60
LOOP UNTIL INKEY$ = CHR$(27)






SUB Draw_Map_Area (ShiftX%, ShiftY%)
STATIC Fc%
FOR Y%% = 0 TO 15
  IF ShiftY% + Y%% > 92 THEN BlockY%% = ShiftY% + Y%% - 93 ELSE BlockY%% = ShiftY% + Y%%
  _PRINTSTRING (768, 32 * Y%%), STR$(BlockY%%) + "  ", Layer(1)

  FOR X%% = 0 TO 23
  'World Scroll Clamps

  IF ShiftX% + X%% > 127 THEN BlockX%% = ShiftX% + X%% - 128 ELSE BlockX%% = ShiftX% + X%%

  _PRINTSTRING (0 + 32 * X%%, 516), STR$(BlockX%%) + "  ", Layer(1)
  '  _PRINTSTRING (0, 550), STR$(BlockX%%) + STR$(BlockY%%)

  SELECT CASE Map(BlockX%%, BlockY%%).ID
    CASE 1 TO 4
    IF G.WaterFrame >= 4 OR G.WaterFrame < 0 THEN G.WaterFrame = 0
    A%% = Animation(0, G.WaterFrame)
    CASE 5 TO 20
    IF G.ShoreFrame >= 7 OR G.ShoreFrame < 0 THEN G.ShoreFrame = 0
    A%% = Animation(1, G.ShoreFrame)
    CASE 45 TO 49
    IF G.LavaFrame >= 4 OR G.LavaFrame < 0 THEN G.LavaFrame = 0
    A%% = Animation(2, G.LavaFrame)
    CASE 139 TO 154
    IF G.ConveFrame >= 4 OR G.ConveFrame < 0 THEN G.ConveFrame = 0
    A%% = Animation(0, G.ConveFrame)
    CASE ELSE
    A%% = 0
  END SELECT
  _PUTIMAGE (32 * X%% - P(0).CD.PixX, 32 * Y%% - P(0).CD.PixY)-STEP(31, 31), Layer(3), Layer(1), (17 * Map(BlockX%%, BlockY%%).ID, 17 * A%%)-STEP(15, 15)
  NEXT X%%
NEXT Y%%

Fc% = Fc% + 1
IF Fc% = 40 THEN Fc% = 0: G.WaterFrame = G.WaterFrame + 1: G.ShoreFrame = G.ShoreFrame + 1: G.LavaFrame = G.LavaFrame + 1
IF Fc% MOD 8 = 0 THEN G.ConveFrame = G.ConveFrame + 1
END SUB

SUB Move_Team
'Move Followers, move all even if some are not present\dead
FOR i%% = 3 TO 1 STEP -1
  P(i%%).CD.Xloc = P(i%% - 1).CD.Xloc
  P(i%%).CD.Yloc = P(i%% - 1).CD.Yloc
  P(i%%).CD.Dirc = P(i%% - 1).CD.Dirc
NEXT
'now move Alis
SELECT CASE P(0).CD.Dirc
  CASE UP
  P(0).CD.Yloc = P(0).CD.Yloc - 1
  CASE DOWN
  P(0).CD.Yloc = P(0).CD.Yloc + 1
  CASE LEFT
  P(0).CD.Xloc = P(0).CD.Xloc - 1
  CASE RIGHT
  P(0).CD.Xloc = P(0).CD.Xloc + 1
END SELECT
'Clamp Values for map scrolling
IF P(0).CD.Yloc = 93 THEN P(0).CD.Yloc = 0
IF P(0).CD.Yloc = -1 THEN P(0).CD.Yloc = 92
IF P(0).CD.Xloc = -128 THEN P(0).CD.Xloc = 0
IF P(0).CD.Xloc = -1 THEN P(0).CD.Xloc = 127
END SUB

SUB Walk_Team
FOR i%% = 1 TO 3
  SELECT CASE P(i%%).CD.Dirc
  CASE DOWN
    P(i%%).CD.PixY = P(i%%).CD.PixY + 2
    IF (ABS(P(i%%).CD.PixY) MOD 32) = 0 THEN G.Moving = FALSE: P(i%%).CD.PixY = 0
  CASE UP
    P(i%%).CD.PixY = P(i%%).CD.PixY - 2
    IF (ABS(P(i%%).CD.PixY) MOD 32) = 0 THEN G.Moving = FALSE: P(i%%).CD.PixY = 0
  CASE LEFT
    P(i%%).CD.PixX = P(i%%).CD.PixX - 2
    IF (ABS(P(i%%).CD.PixX) MOD 32) = 0 THEN G.Moving = FALSE: P(i%%).CD.PixX = 0
  CASE RIGHT
    P(i%%).CD.PixX = P(i%%).CD.PixX + 2
    IF (ABS(P(i%%).CD.PixX) MOD 32) = 0 THEN G.Moving = FALSE: P(i%%).CD.PixX = 0
  END SELECT
NEXT
END SUB

SUB Place_Alis (Frame%%)
IF NOT G.Moving THEN
  _PUTIMAGE (290, 210)-STEP(31, 45), Layer(5), Layer(1), (0 + 17 * P(0).CD.Dirc, 108)-STEP(15, 22)
ELSE
  _PUTIMAGE (290, 210)-STEP(31, 45), Layer(5), Layer(1), (68 + 51 * P(0).CD.Dirc + Animation(2, Frame%%) * 17, 108)-STEP(15, 22)
END IF
END SUB


SUB Place_Team (Frame%%)
IF P(0).Alive THEN t%% = 0 ELSE t%% = -1
IF NOT G.Moving THEN
  IF G.Noah AND P(3).Alive THEN
  t%% = t%% + 1
  _PUTIMAGE (290 - 32 * (P(0).CD.Xloc - P(3).CD.Xloc) + P(3).CD.PixX, 210 - 32 * (P(0).CD.Yloc - P(3).CD.Yloc) + P(3).CD.PixY)-STEP(31, 47), Layer(5), Layer(1), (0 + 17 * P(3).CD.Dirc, 181)-STEP(15, 23)
  END IF
  IF G.Odin AND P(2).Alive THEN
  t%% = t%% + 1
  _PUTIMAGE (290 - 32 * (P(0).CD.Xloc - P(2).CD.Xloc) + P(2).CD.PixX, 210 - 32 * (P(0).CD.Yloc - P(2).CD.Yloc) + P(2).CD.PixY)-STEP(31, 47), Layer(5), Layer(1), (0 + 17 * P(2).CD.Dirc, 156)-STEP(15, 23)
  END IF
  IF G.Myau AND P(1).Alive THEN
  t%% = t%% + 1
  _PUTIMAGE (290 - 32 * (P(0).CD.Xloc - P(1).CD.Xloc) - P(1).CD.PixX, 210 - 32 * (P(0).CD.Yloc - P(1).CD.Yloc) - P(1).CD.PixY)-STEP(31, 45), Layer(5), Layer(1), (0 + 17 * P(1).CD.Dirc, 132)-STEP(15, 22)
  END IF

ELSE
  _PUTIMAGE (290 - 32 * (P(0).CD.Xloc - P(3).CD.Xloc) + P(3).CD.PixX - P(0).CD.PixX, 210 - 32 * (P(0).CD.Yloc - P(3).CD.Yloc) + P(3).CD.PixY - P(0).CD.PixY)-STEP(31, 45), Layer(5), Layer(1), (68 + 51 * P(3).CD.Dirc + Animation(2, Frame%%) * 17, 181)-STEP(15, 22)
  _PUTIMAGE (290 - 32 * (P(0).CD.Xloc - P(2).CD.Xloc) + P(2).CD.PixX - P(0).CD.PixX, 210 - 32 * (P(0).CD.Yloc - P(2).CD.Yloc) + P(2).CD.PixY - P(0).CD.PixY)-STEP(31, 45), Layer(5), Layer(1), (68 + 51 * P(2).CD.Dirc + Animation(2, Frame%%) * 17, 156)-STEP(15, 22)
  'Just you Myau until things work right.
  _PUTIMAGE (290 - 32 * (P(0).CD.Xloc - P(1).CD.Xloc) + P(1).CD.PixX - P(0).CD.PixX, 210 - 32 * (P(0).CD.Yloc - P(1).CD.Yloc) + P(1).CD.PixY - P(0).CD.PixY)-STEP(31, 45), Layer(5), Layer(1), (68 + 51 * P(1).CD.Dirc + Animation(3, Frame%%) * 17, 132)-STEP(15, 22)
  '_PUTIMAGE (290 - 32 * (P(0).CD.Xloc - P(1).CD.Xloc) + P(1).CD.PixX, 210 - 32 * (P(0).CD.Yloc - P(1).CD.Yloc) + P(1).CD.PixY)-STEP(31, 45), Layer(5), Layer(1), (68 + 51 * P(1).CD.Dirc + Animation(3, Frame%%) * 17, 132)-STEP(15, 22)


END IF
END SUB



SUB ClearLayer (L&)
old& = _DEST
_DEST L&
CLS ' ,0
_DEST old&
END SUB

SUB ClearLayerTrans (L&)
old& = _DEST
_DEST L&
CLS , 0
_DEST old&
END SUB

SUB MFI_Loader (FN$)
DIM Size(128) AS LONG, FOffset(128) AS LONG
OPEN FN$ FOR BINARY AS #1
GET #1, , c~%% 'retrieve number of files
FOR I~%% = 1 TO c~%%
  GET #1, , FOffset(I~%%)
  GET #1, , Size(I~%%)
  FOffset&(I~%%) = FOffset&(I~%%) + 1
NEXT I~%%

Layer(3) = LoadGFX(FOffset(2), Size(2)) '
Layer(4) = LoadGFX(FOffset(3), Size(3)) '
Layer(5) = LoadGFX(FOffset(4), Size(4)) '
' Layer(3) = _LOADIMAGE("pstartile_16x16_Game.bmp", 32)
' Layer(4) = _LOADIMAGE("TileMaster.bmp", 32)
' Layer(5) = _LOADIMAGE("CharacterSheet_Master.bmp", 32)


LoadData FOffset(1), Size(1)
F1 = FREEFILE
OPEN "temp.dat" FOR BINARY AS #F1

' CLOSE #1
' IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
END SUB

SUB LoadData (Foff&, Size&)
IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
OPEN "temp.dat" FOR BINARY AS #3
dat$ = SPACE$(Size&)
GET #1, Foff&, dat$
PUT #3, , dat$
CLOSE #3
END SUB

REM '$include:'MFI_Loader2.bi'

FUNCTION LoadGFX& (Foff&, Size&)
IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
OPEN "temp.dat" FOR BINARY AS #3
dat$ = SPACE$(Size&)
GET #1, Foff&, dat$
PUT #3, , dat$
CLOSE #3
LoadGFX& = _LOADIMAGE("temp.dat", 32)
END FUNCTION
Reply




Users browsing this thread: 1 Guest(s)