Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pointlessly Walk or Run forever! (update 0002)
#1
no literally thats all you can do in this code! for now anyway.

Now with interactions. (well a few at the moment)
Now with collisions!
Using a NEW MFI file!


Arrow keys - to move. Only the four main directions, as that's all the character sprites I have(might make diagonal ones... )
Shift keys - to run! Holding down shift goes from walking to running.
Spacebar - exit popup window
ESC -  to quit(outside of popup window)
Enter key - to interact with some objects.

and the world STILL just goes on and on and on and on...................

Code: (Select All)

TYPE World_data
ID AS _BYTE
END TYPE

TYPE Character_data
X AS _UNSIGNED _BYTE
Y AS _UNSIGNED _BYTE
Direction AS _BYTE
Act AS _BYTE
END TYPE

TYPE Game
Event AS _BYTE
END TYPE

DIM SHARED World_Map(255, 255) AS World_data, P AS Character_data
DIM SHARED World_Sprite(255, 255) AS World_data, G AS Game, M$(64)
DIM SHARED Layer(16) AS LONG
CONST Default_Key_Right = 19712, Default_Key_Left = 19200, Default_Key_Up = 18432, Default_Key_Down = 20480
CONST Default_Key_RShift = 100303, Default_Key_LShift = 100304
CONST MOVING = -1: IDLE = 0
CONST TRUE = -1, FALSE = NOT TRUE
'Events
CONST Fire_Event = 1, InterAct_Event = 2, Action_Fail = 3, Treasure_Event = 4, NPC_Event = 5, Gross_Event = 6

SCREEN _NEWIMAGE(800, 600, 32)
Layer(0) = _DISPLAY
Layer(1) = _COPYIMAGE(_DISPLAY)
Layer(2) = _NEWIMAGE(32 * 24, 32 * 24, 32)
'Layer(3) = _LOADIMAGE("testtileset3.bmp", 32)
'Layer(4) = _LOADIMAGE("character_greenhair.bmp", 32)
Layer(5) = _COPYIMAGE(Layer(2))
'Layer(6) = _LOADIMAGE("popupwindow.bmp", 32)
'Layer(7) = _LOADIMAGE("cruknight_dead.bmp", 32)

MFI_Loader "InfWorld.MFI"

_CLEARCOLOR _RGB32(0), Layer(4)
_CLEARCOLOR _RGB32(225, 0, 126), Layer(3)
_CLEARCOLOR _RGB32(34, 34, 35), Layer(3)
_SETALPHA 128, , Layer(6)
_CLEARCOLOR _RGB32(0), Layer(6)
_CLEARCOLOR _RGB32(255), Layer(7)

_PRINTMODE _KEEPBACKGROUND

World_Map(2, 2).ID = 63
World_Sprite(255, 255).ID = 1 'fire(anim)
World_Sprite(5, 25).ID = 2 'Treasure
World_Sprite(25, 10).ID = 3 'Corpse

M$(0) = "OUCH!"
M$(1) = "I'm not ready to be cremated yet!"
M$(2) = "Press SpaceBar"
M$(3) = "HMMMMM...."
M$(4) = "There is nothing I can do with that."
M$(5) = "OOOooo SHINY!"
M$(6) = "I have found some treasure on the Ground!"
M$(7) = "EXCUSE ME!?"
M$(8) = "DISTGUSTING!"
M$(9) = "This guy has been here a while. Nothing"
M$(10) = "to do but get away from the smell!"
UpDate_MapLayer
ClearLayerT Layer(5)

DO
IF _KEYDOWN(Default_Key_Down) AND (Player_Screen_X%% = 0) THEN P.Direction = 0
IF _KEYDOWN(Default_Key_Left) AND (Player_Screen_Y%% = 0) THEN P.Direction = 1
IF _KEYDOWN(Default_Key_Right) AND (Player_Screen_Y%% = 0) THEN P.Direction = 2
IF _KEYDOWN(Default_Key_Up) AND (Player_Screen_X%% = 0) THEN P.Direction = 3

IF _KEYDOWN(Default_Key_Down) OR _KEYDOWN(Default_Key_Left) OR _KEYDOWN(Default_Key_Right) OR _KEYDOWN(Default_Key_Up) THEN P.Act = MOVING ELSE P.Act = IDLE
IF _KEYDOWN(Default_Key_RShift) OR _KEYDOWN(Default_Key_LShift) THEN Speed%% = 2 ELSE Speed%% = 1

IF P.Act = MOVING THEN IF Collision THEN P.Act = IDLE
IF _KEYDOWN(13) THEN G.Event = InterAct_Event: P.Act = IDLE

IF P.Act = MOVING OR Player_Screen_Y%% <> 0 OR Player_Screen_X%% <> 0 THEN
  SELECT CASE P.Direction
  CASE 0
    Player_Screen_Y%% = Player_Screen_Y%% + Speed%%
  CASE 1
    Player_Screen_X%% = Player_Screen_X%% - Speed%%
  CASE 2
    Player_Screen_X%% = Player_Screen_X%% + Speed%%
  CASE 3
    Player_Screen_Y%% = Player_Screen_Y%% - Speed%%
  END SELECT
END IF
IF Player_Screen_Y%% >= (32 + Speed%%) THEN P.Y = P.Y + 1: Player_Screen_Y%% = 0: UpDate_MapLayer
IF Player_Screen_Y%% <= (-32 - Speed%%) THEN P.Y = P.Y - 1: Player_Screen_Y%% = 0: UpDate_MapLayer
IF Player_Screen_X%% <= (-32 - Speed%%) THEN P.X = P.X - 1: Player_Screen_X%% = 0: UpDate_MapLayer
IF Player_Screen_X%% >= (32 + Speed%%) THEN P.X = P.X + 1: Player_Screen_X%% = 0: UpDate_MapLayer

Run_Sprite_Layer

_PUTIMAGE (7, 7)-STEP(567, 567), Layer(2), Layer(1), (64 + Player_Screen_X%%, 64 + Player_Screen_Y%%)-STEP(567, 567)
_PUTIMAGE (7, 7)-STEP(567, 567), Layer(5), Layer(1), (64 + Player_Screen_X%%, 64 + Player_Screen_Y%%)-STEP(567, 567)

_PUTIMAGE (289, 264)-STEP(39, 51), Layer(4), Layer(1), (0 + 21 * frame%%, 0 + 27 * P.Direction)-STEP(19, 25)

_PRINTSTRING (600, 0), STR$(Player_Screen_Y%%), Layer(1)
_PRINTSTRING (600, 18), STR$(Player_Screen_X%%), Layer(1)
_PRINTSTRING (600, 36), STR$(P.X), Layer(1)
_PRINTSTRING (600, 54), STR$(P.Y), Layer(1)
_PRINTSTRING (600, 72), STR$(G.Event), Layer(1)

_PUTIMAGE , Layer(1), Layer(0)
IF G.Event THEN Run_Event_Handler: P.Act = IDLE
ClearLayer Layer(1)
ClearLayerT Layer(5)
IF P.Act = MOVING OR Player_Screen_Y%% <> 0 OR Player_Screen_X%% <> 0 THEN Fc%% = Fc%% + Speed%% ELSE frame%% = 0
IF Fc%% >= 16 THEN frame%% = frame%% + 1: Fc%% = 0
IF frame%% = 8 THEN frame%% = 0

_LIMIT 60
LOOP UNTIL INKEY$ = CHR$(27)

'SCREEN Layer(2)
'LINE (64 + Player_Screen_X%%, 64 + Player_Screen_Y%%)-STEP(567, 567), _RGB32(255, 0, 0), B

SUB Place_Tile (ID_tag AS _BYTE, X AS INTEGER, Y AS INTEGER)
SELECT CASE ID_tag
  CASE 0 'grass default
  _PUTIMAGE (X, Y)-STEP(31, 31), Layer(3), Layer(2), (114, 66)-STEP(15, 15)
  CASE 63 'small crystal
  _PUTIMAGE (X, Y)-STEP(31, 31), Layer(3), Layer(2), (114, 66)-STEP(15, 15)
  _PUTIMAGE (X, Y)-STEP(31, 31), Layer(3), Layer(2), (788, 146)-STEP(15, 15)
END SELECT
END SUB

SUB Place_Sprites (ID_tag AS _BYTE, X AS INTEGER, Y AS INTEGER)
STATIC Fire AS _BYTE, Fire_Frame AS _BYTE
SELECT CASE ID_tag
  CASE 1 'Fire Sprite
  _PUTIMAGE (X, Y - 16)-STEP(31, 31), Layer(3), Layer(5), (66, 66 + 16 * Fire)-STEP(15, 15)
  CASE 2 'treasure
  _PUTIMAGE (X, Y - 16)-STEP(31, 31), Layer(3), Layer(5), (338, 162)-STEP(15, 15)
  CASE 3 'corpse (need to fix layer when finished
  _PUTIMAGE (X, Y - 16)-STEP(39, 43), Layer(7), Layer(5), (0, 0)-STEP(19, 21)

END SELECT
Fire_Frame = Fire_Frame + 1
IF Fire_Frame = 8 THEN Fire = Fire + 1: Fire_Frame = 0
IF Fire = 4 THEN Fire = 0
END SUB

SUB UpDate_MapLayer
ClearLayer Layer(2)
FOR x%% = 0 TO 21
  FOR y%% = 0 TO 21
  PX~%% = x%% + P.X - 11
  py~%% = y%% + P.Y - 11
  Place_Tile World_Map(PX~%%, py~%%).ID, x%% * 32, y%% * 32
  '_PRINTSTRING (x%% * 32, y%% * 32), HEX$(PX~%%) + HEX$(py~%%), Layer(2)
  NEXT
NEXT
END SUB

SUB Run_Sprite_Layer
FOR x%% = 0 TO 21
  FOR y%% = 0 TO 21
  PX~%% = x%% + P.X - 11
  py~%% = y%% + P.Y - 11
  IF World_Sprite(PX~%%, py~%%).ID THEN Place_Sprites World_Sprite(PX~%%, py~%%).ID, x%% * 32, y%% * 32
  NEXT
NEXT
END SUB



FUNCTION Collision%% ()
Result%% = FALSE 'no collision
SELECT CASE P.Direction
  CASE 0
  PY~%% = P.Y + 1
  IF World_Map(P.X, PY~%%).ID <> 0 THEN Result%% = TRUE 'collision detected with world object
  IF World_Sprite(P.X, PY~%%).ID <> 0 THEN Result%% = TRUE: G.Event = TRUE 'collision detected with sprite object
  CASE 1
  PX~%% = P.X - 1
  IF World_Map(PX~%%, P.Y).ID <> 0 THEN Result%% = TRUE 'collision detected with world object
  IF World_Sprite(PX~%%, P.Y).ID <> 0 THEN Result%% = TRUE: G.Event = TRUE 'collision detected with sprite object
  CASE 2
  PX~%% = P.X + 1
  IF World_Map(PX~%%, P.Y).ID <> 0 THEN Result%% = TRUE 'collision detected with world object
  IF World_Sprite(PX~%%, P.Y).ID <> 0 THEN Result%% = TRUE: G.Event = TRUE 'collision detected with sprite object
  CASE 3
  PY~%% = P.Y - 1
  IF World_Map(P.X, PY~%%).ID <> 0 THEN Result%% = TRUE 'collision detected with world object
  IF World_Sprite(P.X, PY~%%).ID <> 0 THEN Result%% = TRUE: G.Event = TRUE 'collision detected with sprite object
END SELECT
Collision = Result%%
END FUNCTION

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

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

SUB Run_Event_Handler
SELECT CASE P.Direction 'get the sprite id that player touched
  CASE 0
  PY~%% = P.Y + 1
  PX~%% = P.X
  Id%% = World_Sprite(P.X, PY~%%).ID
  Id2%% = World_Map(P.X, PY~%%).ID
  CASE 1
  PX~%% = P.X - 1
  PY~%% = P.Y
  Id%% = World_Sprite(PX~%%, P.Y).ID
  Id2%% = World_Map(PX~%%, P.Y).ID
  CASE 2
  PX~%% = P.X + 1
  PY~%% = P.Y
  Id%% = World_Sprite(PX~%%, P.Y).ID
  Id2%% = World_Map(PX~%%, P.Y).ID
  CASE 3
  PY~%% = P.Y - 1
  PX~%% = P.X
  Id%% = World_Sprite(P.X, PY~%%).ID
  Id2%% = World_Map(P.X, PY~%%).ID
END SELECT
IF G.Event = TRUE THEN
  SELECT CASE Id%%
  CASE Fire_Event 'Fire HOT!
    Popup_Message_Window Fire_Event
  CASE 2 ' treasure
    Popup_Message_Window Treasure_Event
    World_Sprite(PX~%%, PY~%%).ID = 0 'remove treasure
  CASE 3 'corpse
    Popup_Message_Window Gross_Event
  END SELECT
ELSEIF G.Event = InterAct_Event THEN
  SELECT CASE Id2%%
  CASE 63 'crystal
    Popup_Message_Window Action_Fail
  END SELECT
END IF

END SUB

SUB Popup_Message_Window (Message%%)
_PUTIMAGE (300 - (376 / 2), 32), Layer(6), Layer(0)

_PRINTSTRING (600, 90), STR$(Message%%), Layer(0)

SELECT CASE Message%%
  CASE Fire_Event
  COLOR _RGB32(0)
  _PRINTSTRING (300 - 8 * LEN(M$(0)) \ 2, 54), M$(0)
  COLOR _RGB32(255)
  _PRINTSTRING (300 - 8 * LEN(M$(1)) \ 2, 96), M$(1)
  COLOR _RGB32(212)
  _PRINTSTRING (300 - 8 * LEN(M$(2)) \ 2, 192), M$(2)
  CASE Action_Fail
  COLOR _RGB32(0)
  _PRINTSTRING (300 - 8 * LEN(M$(3)) \ 2, 54), M$(3)
  COLOR _RGB32(255)
  _PRINTSTRING (300 - 8 * LEN(M$(4)) \ 2, 96), M$(4)
  COLOR _RGB32(212)
  _PRINTSTRING (300 - 8 * LEN(M$(2)) \ 2, 192), M$(2)
  CASE Treasure_Event
  COLOR _RGB32(0)
  _PRINTSTRING (300 - 8 * LEN(M$(5)) \ 2, 54), M$(5)
  COLOR _RGB32(255)
  _PRINTSTRING (300 - 8 * LEN(M$(6)) \ 2, 96), M$(6)
  COLOR _RGB32(212)
  _PRINTSTRING (300 - 8 * LEN(M$(2)) \ 2, 192), M$(2)
  CASE Gross_Event
  COLOR _RGB32(0)
  _PRINTSTRING (300 - 8 * LEN(M$(8)) \ 2, 54), M$(8)
  COLOR _RGB32(255)
  _PRINTSTRING (300 - 8 * LEN(M$(9)) \ 2, 96), M$(9)
  _PRINTSTRING (300 - 8 * LEN(M$(10)) \ 2, 112), M$(10)
  COLOR _RGB32(212)
  _PRINTSTRING (300 - 8 * LEN(M$(2)) \ 2, 192), M$(2)

END SELECT
DO: LOOP UNTIL _KEYDOWN(32)
_KEYCLEAR
G.Event = FALSE
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~%%
'Adjust window,add title, and show music volume warning while finishing loading
_SCREENMOVE 10, 10
_TITLE "'Infinate World' UniKorn ProDucKions 2025"
_KEYCLEAR
Layer(4) = LoadGFX(FOffset(1), Size(1)) '
Layer(3) = LoadGFX(FOffset(2), Size(2)) '
Layer(6) = LoadGFX(FOffset(3), Size(3)) '
Layer(7) = LoadGFX(FOffset(4), Size(4)) '
CLOSE #1
IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
END SUB


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   InfWorld.MFI (Size: 386.67 KB / Downloads: 124)
Reply
#2
I don't know guys, should I keep moving along with this idea?  2 updates now, kind of getting a sense of where its heading. Things are working rather well at the moment.
Reply
#3
I don't know, looks like you are fishing for something.

Didn't I ask you about your MFI sytem ages ago and get answered with silence. OK you missed it?

Anyway how does the author of Dragon Warrior get off with a 0 reputation. I will remedy that! Smile
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#4
I will double your reputation, even though I'm still waiting on that coconut phone!

Pete Big Grin
Reply
#5
(01-23-2025, 09:44 PM)bplus Wrote: Didn't I ask you about your MFI sytem ages ago and get answered with silence. OK you missed it?
was it on this forum or was it on .ORG? I don't remember you asking, though somebody did sometime ago.

anyway,

what did you want to know?
Reply
#6
(01-23-2025, 09:48 PM)Pete Wrote: I will double your reputation, even though I'm still waiting on that coconut phone!

Pete Big Grin
Looks like it was delivered to some tropical island inhabited by 7 cast-a-ways after their 3 hour tour ran afoul of bad weather.

[Image: Coco-Phone.jpg]
Reply
#7
Just as well. It's a real bitch climbing up the cell tower (coconut tree) to hang up the phone anyway, and they always try to string you along for their long-distance plan.

Oh that reminds me. Ginger or Mary Ann? I'm still going with Samantha.

Hey look. You're reputation doubled again!

Pete
Reply
#8
(01-24-2025, 01:36 AM)Cobalt Wrote:
(01-23-2025, 09:44 PM)bplus Wrote: Didn't I ask you about your MFI sytem ages ago and get answered with silence. OK you missed it?
was it on this forum or was it on .ORG? I don't remember you asking, though somebody did sometime ago.

anyway,

what did you want to know?

As I recall it put all assets into single file and/or it had a editor that captured images and modified to clone.

I downloaded to jog my memory.

For a conservative @Pete is pretty liberal with rep points. Right for Cobalt, right?
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#9
Not true. If he comes back and answers either Ginger or Jeanie, two of those points will vanish in the twitch of a nose!

Pete Big Grin
Reply
#10
Obvious choice is Loana!

That's gotta get me 2 points!
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PDF Generation update justsomeguy 7 579 12-22-2025, 12:34 AM
Last Post: justsomeguy
  The Van Halenizer 2.5 update madscijr 11 1,303 11-08-2025, 07:16 AM
Last Post: madscijr
  I have learned something new: how to get a run-time syntax error TDarcos 2 964 10-02-2024, 07:04 PM
Last Post: TDarcos
  Need for Speed High Stakes menu simulator (update 1) paulel 0 539 03-30-2024, 08:50 PM
Last Post: paulel

Forum Jump:


Users browsing this thread: 1 Guest(s)