Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Virtusoroca

Pages: [1] 2
1
QB64 Discussion / Re: Recursively maze creation
« on: June 21, 2020, 05:50:51 pm »
@MasterGy thanks for this one! And thanks @FellippeHeitor for pointing it out. I was trying to implement the backtrack algorithm but had to stop because of work. Hope to come back to the forum in a couple of weeks. Very excited to run and explore this code! Looks very nice! <3

2
Programs / Re: Maze Generator
« on: June 10, 2020, 10:11:34 am »
@bplus great! I will look for it in you maze game. Downloaded it yesterday. Ive looked up some pathfinding algorithms. After the backtrack for the maze I will probably start with the wave propagation (Dijkstra's algorithm) for the pathfinding. A* algorithm seems to be a more complex implementation to me.

3
Programs / Re: Maze Generator
« on: June 10, 2020, 12:22:37 am »
@bplus thanks for the link regarding mazes. Im going to look into it for sure. Working in text mode here, so there is always some different trick to explore. ;)

4
Programs / Re: Maze Generator
« on: June 09, 2020, 09:57:51 pm »
@SierraKen um trying to code the backtrack algorithm. I have little training in math but quite a bit in data arrays. If yoi want to give it a try, look at this video:
. The guy works in C but the best part is in the logical steps. As soon as I finsh my experiment I get back to you.

5
Programs / Re: Maze Generator
« on: June 09, 2020, 03:28:38 am »
I was just working in some maze algorithms! Definetly gona check this one :D

6
@Ashish @bplus <3 <3 <3

No conversion. 100% drawn by hand. :)

7
Final art work, with drawing blocks: codes 178, 177 and 176.
A small gift for you, my friend @Ashish :D

The attachments include de CSV file of the image
It can be embeded into the code usind DATA/READ
Format: CoordX, CoordY, FontColor, BackColor, ASCIIcode, BlockProperty (0/1)

8
Thanks @Ashish! See the attachments: work in progress, defining the pallette. Thinking of a mini game ;D

9
ASCII Editor v2.0

Download the pack and unzip at QB64 root
Pack: BAS + EXE + 6 demos + font file

New: ZoomIn and ZoomOut
Fixed: Error when brush size > 1 hits the border
Fixed: Control characters allowed

Tip: Load your files from ASCII Generator: https://www.qb64.org/forum/index.php?topic=2649.msg118624#msg118624

Note1:  Special characters may not appear in zoom other than 16, 14 and 8. But data is ok in the file
Note2:  Not compatible yet with ASCII Terrain Engine: https://www.qb64.org/forum/index.php?topic=2547.msg117823#msg117823

Let me know you opinion if you try! :)

Code: QB64: [Select]
  1. 'ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
  2. 'º ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ      ASCII TERRAIN ENGINE     ÛÛßßÛÛ ÛÛßßÛÛ º
  3. 'º ÛÛ     Û     ÛÛ     ® Editor Module v2.0 ¯    ÛÛ ÞÛÛ ÛÛÛÛÛ  º
  4. 'º ÛÛ  Û  Û  Û  ÛÛ   (to be integreated in ATE)  ÛÛÜÞÛÛ ÛÛÜÜÛÛ º
  5. 'º    Û  Û  Û        Still rough but usable      ßß          º
  6. 'º ÛÛ  Û  Û  Û  ÛÛ          ------------         ÛÛßßßß ÛÛ  ÛÛ º
  7. 'º ÛÛ  Û     Û  ÛÛ  By Virtusoroca-Brazil, 2020  ÛÛßßÛÛ ÛÛÜÜÛÛ º
  8. 'º ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ          Made in QB64         ÛÛÜÜÛÛ     ÛÛ º
  9. 'ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
  10. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ 1.    SYSTEM SETTINGS
  11. _CONTROLCHR OFF '                                                      Allows ASCII Control Characters to be printed
  12. OPTION BASE 1 '                                                        Sets the begining of arrays at 1
  13. SCREEN _NEWIMAGE(1280, 800, 256) '                                     Set Screen to 1280x800 resolution, 256 colors
  14. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ 2.    SUBPROCEDURES
  15. DECLARE SUB PrintMainMenu'                                             Prints options and settings on screen
  16. DECLARE SUB PrintPallete'                                              Prints color and ASCII palletes on screen
  17. DECLARE SUB HandleOptions'                                             Handles keyboard input (controls program flow)
  18. DECLARE SUB DrawOnCanvas'                                              Handles mouse input on canvas
  19. DECLARE SUB PrintImageDesign'                                          Prints image represented by its design (ASCII code)
  20. DECLARE SUB PrintImageStructure'                                       Prints image represented by its structure (0s and 1s for block property)
  21. DECLARE SUB SaveImageFile'                                             Saves image in CSV format file
  22. DECLARE SUB LoadImageFile'                                             Load image from CSV file
  23. DECLARE SUB LoadImageDefault'                                          Starts new project reloading default canvas
  24. DECLARE SUB ReloadFont'                                                Reloads font size as zoom increases or descreases
  25. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ 3.    VARIABLES
  26. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ 3.1.  Basic variables declaration
  27. DIM SHARED KeyPress AS STRING
  28. DIM SHARED ScreenMode AS STRING
  29. DIM SHARED CurrentFontColor AS INTEGER
  30. DIM SHARED CurrentBackColor AS INTEGER
  31. DIM SHARED CurrentASCII AS INTEGER
  32. DIM SHARED CurrentSize AS INTEGER
  33. DIM SHARED FilePath AS STRING
  34. DIM SHARED FileName AS STRING
  35. DIM SHARED FontResized AS LONG
  36. DIM SHARED FontSize AS INTEGER
  37. DIM SHARED MenuTextY AS INTEGER
  38. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ 3.2.  Basic variables default settings
  39. Pallete = 0
  40. CurrentFontColor = 7
  41. CurrentBackColor = 0
  42. CurrentASCII = 219
  43. CurrentBlock = 0
  44. CurrentSize = 1
  45. ScreenMode = "Design"
  46. FilePath = "./ATE_editor_files/"
  47. FontSize = 16
  48. FontResized = _LOADFONT("PerfectDOSVGA437Win.ttf", FontSize, "monospace")
  49. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ 3.3.  Type variables declaration
  50. TYPE Tiles
  51.     x AS INTEGER ' X Coordinate
  52.     y AS INTEGER ' Y Coordinate
  53.     a AS INTEGER ' Ascii code
  54.     fc AS INTEGER 'FontColor
  55.     bc AS INTEGER 'BackColor
  56.     b AS INTEGER ' Block property (game)
  57. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ 3.4.  Type arrays declaration and default settings
  58. DIM SHARED Tile(50, 100) AS Tiles
  59. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ 4.    MAIN PROCEDURE
  60. LoadImageDefault
  61. PrintImageDesign
  62.     KeyPress = UCASE$(INKEY$)
  63.         ReloadFont FontSize
  64.         MouseX = INT(_MOUSEY / _FONTHEIGHT) + 1
  65.         MouseY = INT(_MOUSEX / _FONTWIDTH) + 1
  66.         DrawOnCanvas
  67.     WEND
  68.     PrintMainMenu
  69.     PrintPallete
  70.     HandleOptions
  71.     _DISPLAY
  72. LOOP UNTIL KeyPress = "Q"
  73. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ 5.    SUBPROCEDURES
  74. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ 5.1.  DrawOnCanvas
  75. SUB DrawOnCanvas
  76.     IF (MouseX > 0 AND MouseX < 50) AND (MouseY > 0 AND MouseY < 100) THEN
  77.         SELECT CASE _MOUSEBUTTON(1)
  78.             CASE -1
  79.                 IF MouseX < 1 THEN MouseX = 1
  80.                 IF MouseX >= 50 THEN MouseX = 50
  81.                 IF MouseY < 1 THEN MouseY = 1
  82.                 IF MouseY >= 100 THEN MouseY = 100
  83.                 CheckX = MouseX + CurrentSize - 1
  84.                 CheckY = MouseY + CurrentSize - 1
  85.                 IF CheckX < 1 THEN CheckX = 1
  86.                 IF CheckX >= 50 THEN CheckX = 50
  87.                 IF CheckY < 1 THEN CheckY = 1
  88.                 IF CheckY >= 100 THEN CheckY = 100
  89.                 FOR A = MouseX TO CheckX
  90.                     FOR B = MouseY TO CheckY
  91.                         Tile(A, B).fc = CurrentFontColor
  92.                         Tile(A, B).bc = CurrentBackColor
  93.                         Tile(A, B).a = CurrentASCII
  94.                         Tile(A, B).b = 0
  95.                         LOCATE A, B: COLOR CurrentFontColor, CurrentBackColor: PRINT CHR$(CurrentASCII);
  96.                     NEXT
  97.                 NEXT
  98.         END SELECT
  99.         SELECT CASE _MOUSEBUTTON(2)
  100.             CASE -1
  101.                 FOR A = MouseX TO MouseX + CurrentSize - 1
  102.                     FOR B = MouseY TO MouseY + CurrentSize - 1
  103.                         Tile(A, B).fc = CurrentFontColor
  104.                         Tile(A, B).bc = CurrentBackColor
  105.                         Tile(A, B).a = CurrentASCII
  106.                         Tile(A, B).b = 1
  107.                         LOCATE A, B: COLOR CurrentFontColor, CurrentBackColor: PRINT CHR$(CurrentASCII);
  108.                     NEXT
  109.                 NEXT
  110.         END SELECT
  111.     END IF
  112. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ 5.2.  PrintMainMenu
  113. SUB PrintMainMenu
  114.     _FONT 16
  115.     COLOR 15, 0: MenuColumnY = INT(1200 / 8) * 0.70
  116.     FOR MenuColumnX = 1 TO 50: LOCATE MenuColumnX, MenuColumnY: PRINT "º";: NEXT
  117.     MenuTextX = 1: MenuTextY = MenuColumnY + 2
  118.     COLOR 15, 0
  119.     LOCATE MenuTextX + 0, MenuTextY: PRINT "CURRENT STATUS"
  120.     COLOR 7, 0
  121.     LOCATE MenuTextX + 2, MenuTextY: PRINT "ScreenMode: "; ScreenMode
  122.     LOCATE MenuTextX + 3, MenuTextY: PRINT "Character:  "; CHR$(CurrentASCII)
  123.     LOCATE MenuTextX + 4, MenuTextY: PRINT "FontColor: "; CurrentFontColor
  124.     LOCATE MenuTextX + 5, MenuTextY: PRINT "BackColor: "; CurrentBackColor
  125.     LOCATE MenuTextX + 6, MenuTextY: PRINT "Preview:    ";: COLOR CurrentFontColor, CurrentBackColor: PRINT CHR$(CurrentASCII);: COLOR 7, 0
  126.     LOCATE MenuTextX + 7, MenuTextY: PRINT "BrushSize: "; CurrentSize
  127.     LOCATE MenuTextX + 8, MenuTextY: PRINT "FontSize:  "; FontSize
  128.     LOCATE MenuTextX + 11, MenuTextY: PRINT "File: ";
  129.     IF FileName = "" THEN PRINT "Not Saved" ELSE PRINT FileName
  130.     LOCATE MenuTextX + 34, MenuTextY: PRINT "MouseClick = PlaceTile";
  131.     LOCATE MenuTextX + 35, MenuTextY: PRINT "LeftClick  = no Block ";
  132.     LOCATE MenuTextX + 36, MenuTextY: PRINT "RightClick = w/ Block"
  133.     LOCATE MenuTextX + 37, MenuTextY: PRINT "A = AsciiCode";
  134.     LOCATE MenuTextX + 38, MenuTextY: PRINT "F = FontColor";
  135.     LOCATE MenuTextX + 39, MenuTextY: PRINT "B = BackColor";
  136.     LOCATE MenuTextX + 40, MenuTextY: PRINT "Z = BrushSize";
  137.     LOCATE MenuTextX + 41, MenuTextY: PRINT "- = ZoomOut";
  138.     LOCATE MenuTextX + 42, MenuTextY: PRINT "+ = ZoomIn";
  139.     LOCATE MenuTextX + 43, MenuTextY: PRINT "D = DesignScreen";
  140.     LOCATE MenuTextX + 44, MenuTextY: PRINT "X = StructureScreen";
  141.     LOCATE MenuTextX + 45, MenuTextY: PRINT "N = NewProject";
  142.     LOCATE MenuTextX + 46, MenuTextY: PRINT "L = LoadFile";
  143.     LOCATE MenuTextX + 47, MenuTextY: PRINT "S = SaveFile";
  144.     LOCATE MenuTextX + 48, MenuTextY: PRINT "Q = Quit";
  145. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ 5.3.  HandleOption
  146. SUB HandleOptions
  147.     _FONT 16
  148.     MenuInputX = 13: MenuColumnY = INT(1200 / 8) * 0.70: MenuTextY = MenuColumnY + 2
  149.     LOCATE MenuInputX, MenuTextY: COLOR 7, 0
  150.     SELECT CASE KeyPress
  151.         CASE "A": INPUT "AsciiCode: ", CurrentASCII: PrintImageDesign
  152.         CASE "F": INPUT "FontColor: ", CurrentFontColor: PrintImageDesign
  153.         CASE "B": INPUT "BackColor: ", CurrentBackColor: PrintImageDesign
  154.         CASE "Z": INPUT "BrushSize: ", CurrentSize
  155.         CASE "D": CLS: ScreenMode = "Design": PrintImageDesign
  156.         CASE "X": CLS: ScreenMode = "Structure": PrintImageStructure
  157.         CASE "N": ScreenMode = "Design": LoadImageDefault
  158.         CASE "S": ScreenMode = "Design": SaveImageFile
  159.         CASE "L": ScreenMode = "Design": LoadImageFile
  160.         CASE "+"
  161.             FontSize = FontSize + 1
  162.             IF FontSize > 16 THEN FontSize = 16
  163.             IF ScreenMode = "Design" THEN PrintImageDesign ELSE PrintImageStructure
  164.         CASE "-"
  165.             FontSize = FontSize - 1
  166.             IF FontSize < 1 THEN FontSize = 1
  167.             IF ScreenMode = "Design" THEN PrintImageDesign ELSE PrintImageStructure
  168.     END SELECT
  169. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ 5.4.  PrintImageDesign
  170. SUB PrintImageDesign
  171.     CLS
  172.     ReloadFont FontSize
  173.     FOR A = 1 TO 50
  174.         FOR B = 1 TO 100
  175.             COLOR Tile(A, B).fc, Tile(A, B).bc
  176.             LOCATE Tile(A, B).x, Tile(A, B).y
  177.             PRINT CHR$(Tile(A, B).a);
  178.             IF B = 100 THEN: LOCATE A, B + 1: PRINT "Û";
  179.             IF FontSize < 16 THEN
  180.                 IF A = 50 THEN: LOCATE A + 1, B: PRINT "Û";
  181.                 LOCATE A + 1, B + 1: PRINT "Û";
  182.             END IF
  183.         NEXT
  184.     NEXT
  185. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ 5.5.  PrintImageStructute
  186. SUB PrintImageStructure
  187.     CLS: COLOR 7, 0
  188.     ReloadFont FontSize
  189.     FOR A = 1 TO 50
  190.         FOR B = 1 TO 100
  191.             IF FontSize < 16 THEN
  192.                 IF B = 100 THEN: LOCATE A, B + 1: PRINT "Û";
  193.                 IF A = 50 THEN: LOCATE A + 1, B: PRINT "Û";
  194.                 LOCATE A + 1, B + 1: PRINT "Û";
  195.             END IF
  196.             SELECT CASE Tile(A, B).b
  197.                 CASE 1
  198.                     LOCATE Tile(A, B).x, Tile(A, B).y
  199.                     PRINT "1";
  200.                 CASE 0
  201.                     LOCATE Tile(A, B).x, Tile(A, B).y
  202.                     PRINT " ";
  203.             END SELECT
  204.         NEXT
  205.     NEXT
  206. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ 5.6.  SaveImageFile
  207. SUB SaveImageFile
  208.     LOCATE 13, MenuTextY: COLOR 7, 0: INPUT "SaveFile: ", FileName
  209.     OPEN FilePath + FileName FOR OUTPUT AS #1
  210.     FOR A = 1 TO 50
  211.         FOR B = 1 TO 100
  212.             WRITE #1, Tile(A, B).x, Tile(A, B).y, Tile(A, B).fc, Tile(A, B).bc, Tile(A, B).a, Tile(A, B).b
  213.         NEXT
  214.     NEXT
  215.     CLOSE #1
  216.     CLS: PrintImageDesign
  217. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ 5.7.  LoadImageFile
  218. SUB LoadImageFile
  219.     LOCATE 13, MenuTextY: COLOR 7, 0: INPUT "LoadFile: ", FileName
  220.     OPEN FilePath + FileName FOR INPUT AS #1
  221.     FOR A = 1 TO 50
  222.         FOR B = 1 TO 100
  223.             INPUT #1, Tile(A, B).x, Tile(A, B).y, Tile(A, B).fc, Tile(A, B).bc, Tile(A, B).a, Tile(A, B).b
  224.         NEXT
  225.     NEXT
  226.     CLOSE #1
  227.     CLS: PrintImageDesign
  228. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ 5.8.  LoadImageDefault
  229. SUB LoadImageDefault
  230.     CLS
  231.     FOR A = 1 TO 50
  232.         FOR B = 1 TO 100
  233.             Tile(A, B).x = A
  234.             Tile(A, B).y = B
  235.             Tile(A, B).a = 0
  236.             Tile(A, B).fc = 7
  237.             Tile(A, B).bc = 0
  238.             Tile(A, B).b = 0
  239.         NEXT
  240.     NEXT
  241. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ 5.9.  RealoadFont
  242. SUB ReloadFont (FontSize)
  243.     IF FontSize = 16 OR FontSize = 14 OR FontSize = 8 THEN
  244.         _FONT FontSize
  245.     ELSE
  246.         FontResized = _LOADFONT("PerfectDOSVGA437Win.ttf", FontSize, "monospace")
  247.         _FONT FontResized
  248.     END IF
  249. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ 5.10. PrintPallete
  250. SUB PrintPallete
  251.     IF Pallete = 1 THEN
  252.         X = 14: MenuColorY = MenuTextY
  253.         'Colors 0 to 15
  254.         LOCATE X, MenuColorY
  255.         FOR A = 0 TO 15
  256.             COLOR A: PRINT "Û";
  257.         NEXT
  258.         X = X + 1
  259.         'Colors 16 to 31
  260.         LOCATE X, MenuColorY
  261.         FOR A = 16 TO 31
  262.             COLOR A: PRINT "Û";
  263.         NEXT
  264.         'Colors 32 to 255
  265.         X = X + 1: L = 1
  266.         FOR A = 32 TO 255
  267.             IF MenuColorY = MenuTextY + 24 THEN
  268.                 X = X + 1
  269.                 MenuColorY = MenuTextY
  270.             END IF
  271.             LOCATE X, MenuColorY
  272.             COLOR A: PRINT "Û";: MenuColorY = MenuColorY + 1
  273.         NEXT
  274.         MenuAsciiY = MenuTextY
  275.         'Ascii 0 to 255
  276.         FOR A = 0 TO 255
  277.             IF MenuAsciiY = MenuTextY + 24 THEN
  278.                 X = X + 1
  279.                 MenuAsciiY = MenuTextY
  280.             END IF
  281.             LOCATE X, MenuAsciiY
  282.             COLOR 7: PRINT CHR$(A);: MenuAsciiY = MenuAsciiY + 1
  283.         NEXT
  284.     END IF
  285. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ 6.   END OF PROGRAM

10
Programs / Re: CRASHLANDED (game, survival, building)
« on: June 01, 2020, 03:02:45 am »
Im enjoying this game a lot! :) almost building the rocket so I can escape 2020! Thanks @MrFreyer for that. Very nice

11
Glad you liked it @SierraKen! Exactly what im going for here. Those retro RPGs. Rogue, Nethack, Dwarf Fortress, but not so complex. My procedural generation experiment is much simplier than those too. I belive we have one of those retro RPGs here in the forum. "Crashlanded" if im not mistaken. Didnt played it yet but looks nice.

12
Still rough but usabe
1. Run code
2. Select theme (UserDefined, BayArea, Archipelago, Swamp, Icelands, Barren, AlienPlanet)
3. Loop trough results and Save the selected Terrain (in the CSV file will be included the terrain block properties)
4. Open CSV file with Editor Module (select StructureMode to see block properties): https://www.qb64.org/forum/index.php?topic=2608.0
5. Load CSV (from Generator or Editor) in ATE MainModule and play (current version not compatible yet): https://www.qb64.org/forum/index.php?topic=2547.0
6. Modify variables as you like and run again

Code: QB64: [Select]
  1. 'ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
  2. 'º ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ      ASCII TERRAIN ENGINE     ÛÛßßÛÛ ÛÛßßÛÛ º
  3. 'º ÛÛ     Û     ÛÛ   ® Generator Module v1.0 ¯   ÛÛ ÞÛÛ ÛÛÛÛÛ  º
  4. 'º ÛÛ  Û  Û  Û  ÛÛ   (to be integreated in ATE)  ÛÛÜÞÛÛ ÛÛÜÜÛÛ º
  5. 'º    Û  Û  Û        Still rough but usable      ßß          º
  6. 'º ÛÛ  Û  Û  Û  ÛÛ          ------------         ÛÛßßßß ÛÛ  ÛÛ º
  7. 'º ÛÛ  Û     Û  ÛÛ  By Virtusoroca-Brazil, 2020  ÛÛßßÛÛ ÛÛÜÜÛÛ º
  8. 'º ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ          Made in QB64         ÛÛÜÜÛÛ     ÛÛ º
  9. 'ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
  10. '================================================================= 1.    SYSTEM SETTINGS
  11. ScreenX = 800: ScreenY = 1200
  12. CharX = 50: CharY = 100
  13. 'FontSize = 16
  14. SCREEN _NEWIMAGE(ScreenY, ScreenX, 256)
  15. '================================================================= 2.    SUBPROCEDURES DECLARATIONS
  16. DECLARE SUB PrintMenu
  17. DECLARE SUB Reload (ScreenX, ScreenY, CharX, CharY)
  18. DECLARE SUB ProceduralGeneration (CharX, CharY, MoundAscii$, MoundFColor, MoundBColor, PlainAscii$, PlainFColor, PlainBColor, WaterAscii$, WaterFColor, WaterBColor, MoundChance, MoundBoldness, WaterLevel)
  19. '================================================================= 3.    VARIABLES DECLARATION
  20. DIM SHARED KeyPress AS STRING
  21. TYPE Map
  22.     x AS INTEGER
  23.     y AS INTEGER
  24.     sum AS INTEGER
  25.     num AS INTEGER
  26.     ascii AS STRING
  27.     block AS INTEGER
  28.     fcolor AS INTEGER
  29.     bcolor AS INTEGER
  30.     check AS INTEGER
  31. REDIM SHARED Tile(1, 1) AS Map
  32. '================================================================= 4.    MAIN PROCEDURE
  33.     PrintMenu
  34.     Reload ScreenX, ScreenY, CharX, CharY
  35.     ProceduralGeneration CharX, CharY, MoundAscii$, MoundFColor, MoundBColor, PlainAscii$, PlainFColor, PlainBColor, WaterAscii$, WaterFColor, WaterBColor, MoundChance, MoundBoldness, WaterLevel
  36.     KeyPress = UCASE$(INKEY$)
  37.     SELECT CASE KeyPress
  38.         '========================================================= 4.1.  UserDefined
  39.         CASE CHR$(0) + CHR$(59)
  40.             MoundAscii$ = "²": MoundFColor = 6: MoundBColor = 7
  41.             PlainAscii$ = "Û": PlainFColor = 2: PlainBColor = 0
  42.             WaterAscii$ = "Û": WaterFColor = 3: WaterBColor = 0
  43.             MoundChance = 0: MoundBoldness = 55: WaterLevel = 1
  44.             '===================================================== 4.2.  BayArea
  45.         CASE CHR$(0) + CHR$(60)
  46.             MoundAscii$ = "²": MoundFColor = 2: MoundBColor = 7
  47.             PlainAscii$ = "Û": PlainFColor = 2: PlainBColor = 0
  48.             WaterAscii$ = "Û": WaterFColor = 3: WaterBColor = 0
  49.             MoundChance = 0: MoundBoldness = 55: WaterLevel = 1
  50.             '===================================================== 4.3.  Archipelago
  51.         CASE CHR$(0) + CHR$(61)
  52.             MoundAscii$ = "^": MoundFColor = 6: MoundBColor = 2
  53.             PlainAscii$ = "Û": PlainFColor = 2: PlainBColor = 0
  54.             WaterAscii$ = "Û": WaterFColor = 3: WaterBColor = 0
  55.             MoundChance = 0: MoundBoldness = 35: WaterLevel = 2
  56.             '===================================================== 4.4.  Swamp
  57.         CASE CHR$(0) + CHR$(62)
  58.             MoundAscii$ = "°": MoundFColor = 2: MoundBColor = 0
  59.             PlainAscii$ = "°": PlainFColor = 6: PlainBColor = 0
  60.             WaterAscii$ = "°": WaterFColor = 6: WaterBColor = 3
  61.             MoundChance = 10: MoundBoldness = 25: WaterLevel = 2
  62.             '===================================================== 4.5.  Icelands
  63.         CASE CHR$(0) + CHR$(63)
  64.             MoundAscii$ = "^": MoundFColor = 29: MoundBColor = 27
  65.             PlainAscii$ = "Û": PlainFColor = 27: PlainBColor = 0
  66.             WaterAscii$ = "Û": WaterFColor = 11: WaterBColor = 0
  67.             MoundChance = 30: MoundBoldness = 0: WaterLevel = 1
  68.             '===================================================== 4.6.  Barren
  69.         CASE CHR$(0) + CHR$(64)
  70.             MoundAscii$ = " ": MoundFColor = 14: MoundBColor = 6
  71.             PlainAscii$ = ".": PlainFColor = 14: PlainBColor = 6
  72.             WaterAscii$ = "": WaterFColor = 14: WaterBColor = 6
  73.             MoundChance = 5: MoundBoldness = 45: WaterLevel = 2
  74.             '===================================================== 4.7.  AlienPlanet
  75.         CASE CHR$(0) + CHR$(65)
  76.             MoundAscii$ = " ": MoundFColor = 21: MoundBColor = 18
  77.             PlainAscii$ = "^": PlainFColor = 0: PlainBColor = 18
  78.             WaterAscii$ = "°": WaterFColor = 18: WaterBColor = 5
  79.             MoundChance = 5: MoundBoldness = 45: WaterLevel = 5
  80.             '=====================================================
  81.             'CASE "-": FontSize = FontSize - 1
  82.             'CASE "+": FontSize = FontSize + 1
  83.         CASE "S"
  84.             SaveImageFile CharX, CharY
  85.     END SELECT
  86.     '=============================================================
  87. LOOP UNTIL KeyPress = "Q"
  88. '================================================================= 5.   SUBROUTINES
  89. '================================================================= 5.1. PrintMenu
  90. SUB PrintMenu
  91.     FOR MenuColumnX = 1 TO 50
  92.         LOCATE MenuColumnX, 101: COLOR 7, 0: PRINT "º";
  93.     NEXT
  94.     LOCATE 1, 103: PRINT "SELECT OPTION"
  95.     LOCATE 3, 103: PRINT "F1 = UserCustomized"
  96.     LOCATE 4, 103: PRINT "F2 = BayArea"
  97.     LOCATE 5, 103: PRINT "F3 = Archipelago"
  98.     LOCATE 6, 103: PRINT "F4 = Swamp"
  99.     LOCATE 7, 103: PRINT "F5 = Icelands"
  100.     LOCATE 8, 103: PRINT "F6 = Barren"
  101.     LOCATE 9, 103: PRINT "F7 = AlienPlanet"
  102.     LOCATE 11, 103: PRINT "S  = SaveFile"
  103. '================================================================= 5.2. Reload
  104. SUB Reload (ScreenX, ScreenY, CharX, CharY)
  105.     '    font& = _LOADFONT("PerfectDOSVGA437Win.ttf", FontSize, "monospace")
  106.     '    _FONT font&
  107.     '    CharX = INT(ScreenX / _FONTHEIGHT)
  108.     '    CharY = INT(ScreenY / _FONTWIDTH)
  109.     REDIM Tile(CharX, CharY) AS Map
  110.     FOR X = 1 TO CharX
  111.         FOR Y = 1 TO CharY
  112.             Tile(X, Y).block = 0
  113.             Tile(X, Y).check = 0
  114.             Tile(X, Y).num = 0
  115.             Tile(X, Y).sum = 0
  116.             Tile(X, Y).x = X
  117.             Tile(X, Y).y = Y
  118.         NEXT
  119.     NEXT
  120. '================================================================= 5.3. ProceduralGeneration
  121. SUB ProceduralGeneration (CharX, CharY, MoundAscii$, MoundFColor, MoundBColor, PlainAscii$, PlainFColor, PlainBColor, WaterAscii$, WaterFColor, WaterBColor, MoundChance, MoundBoldness, WaterLevel)
  122.     '============================================================= 5.3.1. MoundChance
  123.     FOR X = 1 TO CharX
  124.         FOR Y = 1 TO CharY
  125.             Char = INT(RND * 100)
  126.             IF Char >= 0 AND Char <= MoundChance THEN
  127.                 Tile(X, Y).ascii = MoundAscii$: Tile(X, Y).fcolor = MoundFColor: Tile(X, Y).bcolor = MoundBColor
  128.                 Tile(X, Y).num = 1
  129.                 Tile(X, Y).check = 1
  130.                 LOCATE X, Y: COLOR Tile(X, Y).fcolor, Tile(X, Y).bcolor: PRINT Tile(X, Y).ascii;
  131.             END IF
  132.         NEXT
  133.     NEXT
  134.     '============================================================= 5.3.2. MoundBoldness
  135.     FOR X = 1 TO CharX - 1
  136.         FOR Y = 1 TO CharY - 1
  137.             IF Tile(X, Y).check = 0 THEN
  138.                 Char = INT(RND * 100)
  139.                 IF Char >= 0 AND Char <= MoundBoldness THEN
  140.                     FOR Z = -1 TO 1
  141.                         Tile(X, Y).sum = Tile(X, Y).sum + Tile(X - 1, Y - 1).num
  142.                         Tile(X, Y).sum = Tile(X, Y).sum + Tile(X - 1, Y + 0).num
  143.                         Tile(X, Y).sum = Tile(X, Y).sum + Tile(X - 1, Y + 1).num
  144.                         Tile(X, Y).sum = Tile(X, Y).sum + Tile(X + 0, Y - 1).num
  145.                         Tile(X, Y).sum = Tile(X, Y).sum + Tile(X + 0, Y + 1).num
  146.                         Tile(X, Y).sum = Tile(X, Y).sum + Tile(X + 1, Y - 1).num
  147.                         Tile(X, Y).sum = Tile(X, Y).sum + Tile(X + 1, Y + 0).num
  148.                         Tile(X, Y).sum = Tile(X, Y).sum + Tile(X + 1, Y + 1).num
  149.                     NEXT
  150.                 END IF
  151.                 IF Tile(X, Y).sum >= 1 THEN '===================== Higher the sum restrictions for MoundBoldness, higher the WaterLevel
  152.                     Tile(X, Y).ascii = MoundAscii$: Tile(X, Y).fcolor = MoundFColor: Tile(X, Y).bcolor = MoundBColor
  153.                     Tile(X, Y).num = 1
  154.                     Tile(X, Y).check = 2
  155.                     LOCATE X, Y: COLOR Tile(X, Y).fcolor, Tile(X, Y).bcolor: PRINT Tile(X, Y).ascii;
  156.                 END IF
  157.             END IF
  158.         NEXT
  159.     NEXT
  160.     '============================================================= 5.3.3. Plains (surrounding Mounds)
  161.     FOR X = 1 TO CharX - 1
  162.         FOR Y = 1 TO CharY - 1
  163.             IF Tile(X, Y).check = 0 THEN
  164.                 Tile(X, Y).sum = Tile(X, Y).sum + Tile(X - 1, Y - 1).num
  165.                 Tile(X, Y).sum = Tile(X, Y).sum + Tile(X - 1, Y + 0).num
  166.                 Tile(X, Y).sum = Tile(X, Y).sum + Tile(X - 1, Y + 1).num
  167.                 Tile(X, Y).sum = Tile(X, Y).sum + Tile(X + 0, Y - 1).num
  168.                 Tile(X, Y).sum = Tile(X, Y).sum + Tile(X + 0, Y + 1).num
  169.                 Tile(X, Y).sum = Tile(X, Y).sum + Tile(X + 1, Y - 1).num
  170.                 Tile(X, Y).sum = Tile(X, Y).sum + Tile(X + 1, Y + 0).num
  171.                 Tile(X, Y).sum = Tile(X, Y).sum + Tile(X + 1, Y + 1).num
  172.                 IF Tile(X, Y).sum >= WaterLevel THEN
  173.                     Tile(X, Y).ascii = PlainAscii$: Tile(X, Y).fcolor = PlainFColor: Tile(X, Y).bcolor = PlainBColor
  174.                     Tile(X, Y).check = 3
  175.                     LOCATE X, Y: COLOR Tile(X, Y).fcolor, Tile(X, Y).bcolor: PRINT Tile(X, Y).ascii;
  176.                 END IF
  177.             END IF
  178.         NEXT
  179.     NEXT
  180.     '============================================================= 5.3.4. Water (fill the rest in) [for WaterLevel see MoundBoldness)
  181.     FOR X = 1 TO CharX
  182.         FOR Y = 1 TO CharY
  183.             IF Tile(X, Y).check = 0 THEN
  184.                 Tile(X, Y).ascii = WaterAscii$: Tile(X, Y).fcolor = WaterFColor: Tile(X, Y).bcolor = WaterBColor: Tile(X, Y).block = 1
  185.                 LOCATE X, Y: COLOR Tile(X, Y).fcolor, Tile(X, Y).bcolor: PRINT Tile(X, Y).ascii;
  186.             END IF
  187.         NEXT
  188.     NEXT
  189.     SLEEP
  190. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ 5.4. SaveImageFile
  191. SUB SaveImageFile (CharX, CharY)
  192.     LOCATE 12, 103: COLOR 7, 0: INPUT "SaveFile: ", FileName$
  193.     OPEN FileName$ FOR OUTPUT AS #1
  194.     FOR A = 1 TO CharX
  195.         FOR B = 1 TO CharY
  196.             WRITE #1, Tile(A, B).x, Tile(A, B).y, Tile(A, B).fcolor, Tile(A, B).bcolor, ASC(Tile(A, B).ascii), Tile(A, B).block
  197.         NEXT
  198.     NEXT
  199.     CLOSE #1
  200.     SLEEP
  201. '================================================================= 6. END OF PROGRAM
  202.  

13
QB64 Discussion / Re: QB64SOURCECODE.COM
« on: May 26, 2020, 04:04:10 pm »
The simplest way is as you described. Its two independent characters that cant ocuppy the same space. If the space is the same, then collision. Done.

But imagine first that you have layers. Some characters you can walk through, other you cant. It will require arrays. Maybe you want the forefront character to inherit the background color from below  or have its spaces ignored for "transparency" effect. And then imagine youre dealing with a non rectacular set of characters that may have its own collision structure, independently of its design layer. For the collision you will need to do a "player structure layer" calculation against a "terrain structure layer", for each ajdecent array position, dependent on player size, shape, direction and speed.

Thats what I did in my engine, in a clumsy way I believe. For example, you can make the player with up to 3x3 characters (for now), but that is blocked at its corners only, passing through blocks that fit into it (moving over those characters that dont block it, with transparency effect). Its customizable shape will fit perfectly in the terrain structure, like tetris. None of this requiere any particulary dificult function, but the whole construct has its own complexity, different from a pixel/graphics approach.

For the code mess i manage to pull off trying this, take a look at my ASCII Terrain Engine, MovePlayer function (I mean, Sub). Ashish helped me with that mess and in the next version this segment will much more clear and compact.

14
QB64 Discussion / Re: QB64SOURCECODE.COM
« on: May 26, 2020, 01:56:26 pm »
Hi @TerryRitchie. I was follwing your tutorial even before join the community. Very broad and helpful. Thanks for the effort. A humble suggestion: maybe some comments could be added in tasks 16 (transparency) and 17 (collision) regarding games based on text characters. It sounds simple but there are some tricky aspects to it, specially in edge-sensitive collision detection between complex (non-rectangular) character sets. I had a hard time figuring that out and ended up hard coding the calculations. @Ashish help me to abstract it further (I didnt posted that yet). Tutoriais on these topics would be great I think. Im willing to help but not sure if Im up to the task.

15
Programs / Re: Build yourself a fancy menu!
« on: May 20, 2020, 11:28:07 pm »
Deal! Thanks again for sharing this. <3

Pages: [1] 2