Author Topic: Its Been A While! But here, Try This!!  (Read 3927 times)

0 Members and 1 Guest are viewing this topic.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Its Been A While! But here, Try This!!
« on: May 12, 2021, 02:55:46 pm »
Walk the world of Palma!
What more can be said? Explore the over-world with out boundaries!
No collision checking in this version so walk where you want.
Marvel at the amazing animation!
Drool over the lush 16 color palette!
And be left Wanting More!

Seriously though, give it a try. What do you think? Its been a while since I have posted anything so wanted to give you guys something.

Controls:
Arrow keys move character.
ESC key quits.

And as always don't forget to download the resource file attached.
and Subscribe, Like, Share and Comment below! XD (all my kingdom for few smilies!)
Code: QB64: [Select]
  1. 'World of Palma; Exploration demo
  2. '5/12/2021
  3. 'Collision checking OFF version
  4. 'Cobalt
  5. TYPE WorldTiles
  6.  Is_Walkable AS _BYTE
  7.  Is_Animated AS _BYTE
  8.  Encounter_Group AS _BYTE 'what types of creature encounters possible
  9.  Is_Village AS _BYTE
  10.  Is_Cave AS _BYTE 'Covers all Cave-like locations
  11. TYPE PlayerTemp
  12.  Wx AS INTEGER
  13.  Wy AS INTEGER
  14.  Tx AS _BYTE
  15.  Ty AS _BYTE
  16.  Fr AS _BYTE
  17.  
  18. SCREEN _NEWIMAGE(640, 480, 32)
  19. DIM SHARED Map(128, 96) AS WorldTiles, P AS PlayerTemp
  20. DIM SHARED char&, MapAni&, TileX2&, Temp&, frame%, FPSC%, g.facing AS _BYTE, g.moving AS _BYTE
  21. DIM SHARED Conv&, AlisAnim(4) AS _BYTE
  22. DIM SHARED AnimationOrder(3, 8) '8 frames for sync between Waves\marsh and Shore animations
  23. Temp& = _NEWIMAGE(640, 480, 32)
  24.  
  25. MFI_Loader "PS_Overworld_test.MFI"
  26.  
  27. _CLEARCOLOR _RGB32(62), char&
  28. 'place the conveyor system in corect world location
  29. CONST Conveyor_1_Pos_X = 32 * 73
  30. CONST Conveyor_1_Pos_Y = 32 * 46 + 8
  31. CONST Conveyor_2_Pos_X = 32 * 70 + 8
  32. CONST Conveyor_2_Pos_Y = 32 * 49
  33. CONST Conveyor_Frame_Speed = 2
  34. '--------------------------------------------------
  35. DATA 0,1,2,3,4,4,1,0: 'shore animation order
  36. FOR i%% = 0 TO 7
  37.  READ AnimationOrder(1, i%%)
  38. NEXT i%%
  39. DATA 0,1,2,1: 'animation frame order
  40. FOR i%% = 0 TO 3
  41.  READ AlisAnim(i%%)
  42. NEXT i%%
  43.  
  44. CONST TRUE = -1, FALSE = NOT TRUE
  45. CONST Default_Key_Right = 19712, Default_Key_Left = 19200, Default_Key_Up = 18432, Default_Key_Down = 20480
  46. CONST Default_A_Button = 32, Default_B_Button = 13, Default_Start_Button = 65, Default_Select_Button = 66
  47. CONST down = 0, up = 1, right = 2, left = 3
  48.  
  49. ON TIMER(T2!, 1) FPS
  50.  
  51. TIMER(T2!) ON
  52. Mapx% = 60
  53. Mapy% = 40
  54. P.Wx = 70
  55. P.Wy = 45
  56.  Map_Loader_tiled_Base P.Wx, P.Wy, P.Tx, P.Ty 'Mapx%, Mapy%, Playrx%, Playry%
  57.  _PRINTSTRING (0, 0), STR$(FPSC%), Temp&
  58.  _PRINTSTRING (48, 0), STR$(P.Wx), Temp&
  59.  _PRINTSTRING (96, 0), STR$(P.Wy), Temp&
  60.  Place_Alis
  61.  _PUTIMAGE , Temp&, _DISPLAY
  62.  frame% = frame% + 1
  63.  '-----------------Controls------------------
  64.  IF _KEYDOWN(Default_Key_Up) AND (NOT g.moving) THEN g.facing = up: g.moving = TRUE
  65.  IF _KEYDOWN(Default_Key_Left) AND (NOT g.moving) THEN g.facing = left: g.moving = TRUE
  66.  IF _KEYDOWN(Default_Key_Right) AND (NOT g.moving) THEN g.facing = right: g.moving = TRUE
  67.  IF _KEYDOWN(Default_Key_Down) AND (NOT g.moving) THEN g.facing = down: g.moving = TRUE
  68.  IF _KEYDOWN(27) THEN exitflag%% = -1
  69.  '--------------------------------------------
  70.  '----------------Movement--------------------
  71.  IF g.moving THEN
  72.   SELECT CASE g.facing
  73.    CASE up
  74.     P.Ty = P.Ty + 2
  75.     IF (ABS(P.Ty) MOD 32) = 0 THEN g.moving = FALSE: P.Wy = P.Wy - 1: P.Ty = 0
  76.     IF NOT _KEYDOWN(Default_Key_Up) THEN Ft%% = 0: P.Fr = 0 ELSE g.moving = TRUE
  77.    CASE down
  78.     P.Ty = P.Ty - 2
  79.     IF (P.Ty MOD 32) = 0 THEN g.moving = FALSE: P.Wy = P.Wy + 1: P.Ty = 0
  80.     IF NOT _KEYDOWN(Default_Key_Down) THEN Ft%% = 0: P.Fr = 0 ELSE g.moving = TRUE
  81.    CASE left
  82.     P.Tx = P.Tx + 2
  83.     IF (ABS(P.Tx) MOD 32) = 0 THEN g.moving = FALSE: P.Wx = P.Wx - 1: P.Tx = 0
  84.     IF NOT _KEYDOWN(Default_Key_Left) THEN Ft%% = 0: P.Fr = 0 ELSE g.moving = TRUE
  85.    CASE right
  86.     P.Tx = P.Tx - 2
  87.     IF (P.Tx MOD 32) = 0 THEN g.moving = FALSE: P.Wx = P.Wx + 1: P.Tx = 0
  88.     IF NOT _KEYDOWN(Default_Key_Right) THEN Ft%% = 0: P.Fr = 0 ELSE g.moving = TRUE
  89.  IF g.moving THEN Ft%% = Ft%% + 1
  90.  IF Ft%% = 8 THEN P.Fr = P.Fr + 1: Ft%% = 0
  91.  IF P.Fr = 4 THEN P.Fr = 0
  92.  'Correct for map wrap
  93.  IF P.Wx = 128 THEN P.Wx = 0
  94.  IF P.Wx = -1 THEN P.Wx = 127
  95.  IF P.Wy = 96 THEN P.Wy = 0
  96.  IF P.Wy = -1 THEN P.Wy = 95
  97.  '--------------------
  98.  
  99.  _LIMIT 60
  100. LOOP UNTIL exitflag%%
  101. TIMER(T2!) OFF
  102.  
  103.  
  104.  
  105. SUB Map_Loader_tiled_Base (X1%, Y1%, Sx%, Sy%)
  106.  STATIC SubFrame(3) AS _BYTE, MainFrame(3) AS _BYTE, Triggered%%
  107.  FOR x% = -1 TO 20
  108.   FOR y% = -1 TO 15
  109.    mx% = X1% + x%
  110.    my% = Y1% + y%
  111.    '------Adjust for map wrap around------
  112.    IF mx% < 0 THEN mx% = 128 + mx% 'use addition cause mx% is a negative
  113.    IF mx% > 127 THEN mx% = mx% - 128
  114.    IF my% < 0 THEN my% = 96 + my% 'use addition cause my% is a negative
  115.    IF my% > 95 THEN my% = my% - 96
  116.    '--------------------------------------
  117.    'main map tiles
  118.    _PUTIMAGE (Sx% + x% * 32, Sy% + y% * 32)-STEP(31, 31), TileX2&, Temp&, (0 + Map(mx%, my%).Id * 34, 0)-STEP(31, 31)
  119.    'animated map tiles
  120.    IF Map(mx%, my%).Is_Animated THEN
  121.     SELECT CASE Map(mx%, my%).Id
  122.      CASE 1 TO 4 'waves
  123.       _PUTIMAGE (Sx% + x% * 32, Sy% + y% * 32)-STEP(31, 31), MapAni&, Temp&, (544 + MainFrame(1) * 34, 0)-STEP(31, 31)
  124.      CASE 21 TO 25 'marsh
  125.       _PUTIMAGE (Sx% + x% * 32, Sy% + y% * 32)-STEP(31, 31), MapAni&, Temp&, (544 + (Map(mx%, my%).Id - 21) * 34, 34 + MainFrame(1) * 34)-STEP(31, 31)
  126.      CASE 5 TO 20 'shore
  127.       _PUTIMAGE (Sx% + x% * 32, Sy% + y% * 32)-STEP(31, 31), MapAni&, Temp&, ((Map(mx%, my%).Id - 5) * 34, AnimationOrder(1, MainFrame(2)) * 34)-STEP(31, 31)
  128.     END SELECT
  129.    END IF
  130.   NEXT y%
  131.  NEXT x%
  132.  'Horizontal conveyor
  133.  _PUTIMAGE (Sx% + Conveyor_1_Pos_X - (X1% * 32), Sy% + Conveyor_1_Pos_Y - (Y1% * 32)), Conv&, Temp&, (0, 0 + (MainFrame(0) * 34))-STEP(255, 31)
  134.  'vertical conveyor
  135.  _PUTIMAGE (Sx% + Conveyor_2_Pos_X - (X1% * 32), Sy% + Conveyor_2_Pos_Y - (Y1% * 32)), Conv&, Temp&, (257 + (MainFrame(0) * 34), 0)-STEP(31, 223)
  136.  FOR i%% = 0 TO 2
  137.   SubFrame(i%%) = SubFrame(i%%) + 1
  138.   IF SubFrame(0) = 5 + Conveyor_Frame_Speed THEN MainFrame(0) = MainFrame(0) + Conveyor_Frame_Speed: SubFrame(0) = 0
  139.   IF SubFrame(1) = 16 THEN MainFrame(1) = MainFrame(1) + 1: SubFrame(1) = 0
  140.   IF SubFrame(2) = 24 THEN MainFrame(2) = MainFrame(2) + 1: SubFrame(2) = 0
  141.  NEXT i%%
  142.  IF MainFrame(0) = 8 THEN MainFrame(0) = 0
  143.  IF MainFrame(1) = 4 THEN MainFrame(1) = 0
  144.  IF MainFrame(2) = 8 THEN MainFrame(2) = 0
  145.  
  146. SUB FPS
  147.  ' STATIC LastCount%
  148.  FPSC% = frame%
  149.  frame% = 0
  150.  
  151. SUB Place_Alis
  152.  IF NOT g.moving THEN
  153.   _PUTIMAGE (290, 210)-STEP(31, 45), char&, Temp&, (0 + 17 * g.facing, 120)-STEP(15, 22)
  154.   _PUTIMAGE (290, 210)-STEP(31, 45), char&, Temp&, (68 + 51 * g.facing + AlisAnim(P.Fr) * 17, 120)-STEP(15, 22)
  155.  
  156. SUB MFI_Loader (FN$)
  157.  DIM Size(128) AS LONG, FOffset(128) AS LONG
  158.  GET #1, , c~%% 'retrieve number of files
  159.  FOR I~%% = 1 TO c~%%
  160.   GET #1, , FOffset(I~%%)
  161.   GET #1, , Size(I~%%)
  162.   FOffset&(I~%%) = FOffset&(I~%%) + 1
  163.  NEXT I~%%
  164.  
  165.  TileX2& = LoadGFX(FOffset(1), Size(1)) ' _LOADIMAGE("gfx\maps\PalmaTiles2x2.bmp", 32) '_NEWIMAGE(640, 480, 32)
  166.  Conv& = LoadGFX(FOffset(2), Size(2)) '_LOADIMAGE("gfx\maps\conveyoranim.bmp", 32) 'Conveyor
  167.  MapAni& = LoadGFX(FOffset(3), Size(3)) '_LOADIMAGE("gfx\maps\mapanimation.bmp", 32) 'Water, shore, and marsh frames
  168.  char& = LoadGFX(FOffset(4), Size(4)) '_LOADIMAGE("gfx\CharacterSheetC.png", 32) '
  169.  LoadData FOffset(5), Size(5)
  170.  CLOSE #1
  171.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  172.  
  173. SUB LoadData (Foff&, Size&)
  174.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  175.  OPEN "temp.dat" FOR BINARY AS #3
  176.  dat$ = SPACE$(Size&)
  177.  GET #1, Foff&, dat$
  178.  PUT #3, , dat$
  179.  CLOSE #3
  180.  
  181.  F1 = FREEFILE
  182.  OPEN "temp.dat" FOR BINARY AS #F1
  183.  ' OPEN "PhantasyStarPalma2.Dat" FOR BINARY AS #1
  184.  GET #F1, , Map()
  185.  ' CLOSE
  186.  CLOSE #F1
  187.  
  188.  
  189. REM '$include:'MFI_Loader2.bi'
  190.  
  191. FUNCTION LoadGFX& (Foff&, Size&)
  192.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  193.  OPEN "temp.dat" FOR BINARY AS #3
  194.  dat$ = SPACE$(Size&)
  195.  GET #1, Foff&, dat$
  196.  PUT #3, , dat$
  197.  CLOSE #3
  198.  LoadGFX& = _LOADIMAGE("temp.dat", 32)
  199.  
  200. FUNCTION LoadFFX& (Foff&, Size&, Fize%%)
  201.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  202.  OPEN "temp.dat" FOR BINARY AS #3
  203.  dat$ = SPACE$(Size&)
  204.  GET #1, Foff&, dat$
  205.  PUT #3, , dat$
  206.  CLOSE #3
  207.  LoadFFX& = _LOADFONT("temp.dat", Fize%%, "monospace")
  208.  
  209. FUNCTION LoadSFX& (Foff&, Size&)
  210.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  211.  OPEN "temp.dat" FOR BINARY AS #3
  212.  dat$ = SPACE$(Size&)
  213.  GET #1, Foff&, dat$
  214.  PUT #3, , dat$
  215.  CLOSE #3
  216.  LoadSFX& = _SNDOPEN("temp.dat")
  217.  
* PS_Overworld_test.MFI (Filesize: 133.46 KB, Downloads: 228)
Granted after becoming radioactive I only have a half-life!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Its Been A While! But here, Try This!!
« Reply #1 on: May 12, 2021, 03:30:12 pm »
Hey nice 143 KB code does allot!

Hey she can walk on water!
 
image_2021-05-12_152920.png


I like how waves are hitting shore line, nice effect.

Offline justsomeguy

  • Newbie
  • Posts: 47
    • View Profile
Re: Its Been A While! But here, Try This!!
« Reply #2 on: May 12, 2021, 03:50:35 pm »
Very cool! Nice variety of tiles and cool animations. Looking forward to your progress.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Its Been A While! But here, Try This!!
« Reply #3 on: May 12, 2021, 03:56:57 pm »
Cool demo... No problems on my Linux machine. Question: What exactly does the ".MFI" file do?
Logic is the beginning of wisdom.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Its Been A While! But here, Try This!!
« Reply #4 on: May 12, 2021, 04:50:42 pm »
Cool demo... No problems on my Linux machine. Question: What exactly does the ".MFI" file do?
Thank you,

A MFI file stores all the resources; Images, sounds, data, ect.
Its kind-of my own proprietary file packing format, though its super simple and based off of other formats that do pretty much the exact same thing. It was used a lot in video games in the 80s and 90s.
Found its easier than attaching lots of little files. And not everybody likes zips\rars\ or 7z files for what ever reason.
Granted after becoming radioactive I only have a half-life!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Its Been A While! But here, Try This!!
« Reply #5 on: May 12, 2021, 04:54:01 pm »
Hey nice 143 KB code does allot!

Hey she can walk on water!
 
image_2021-05-12_152920.png


I like how waves are hitting shore line, nice effect.
Thank you!

Especially when the actual code that does everything is 8k, and 1/4 of that is the MFI_Loader code.
Considering the "Monster" Dragon Warrior turned out to be, this should be really compact. Maybe a Middle aged dog can still learn new tricks after all?
Granted after becoming radioactive I only have a half-life!

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Its Been A While! But here, Try This!!
« Reply #6 on: May 12, 2021, 10:15:02 pm »
Looks like a great start.  Giving it a whirl now.   Yeah, I also like the water edge animation.  Adventure games are one of my weaknesses.  Kudos to you rolling your own single resource file format. 

- Dav

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Its Been A While! But here, Try This!!
« Reply #7 on: May 13, 2021, 04:36:16 am »
Amazing! The graphics are very pleasing to my eyes. :D :)
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials