Author Topic: ASCII Editor (2 demos included) | to be integrated into ASCII Terrain Engine  (Read 3284 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline Virtusoroca

  • Newbie
  • Posts: 24
    • View Profile
To be integrated into ASCII Terrain Engine (for Game Developers)
- Still rough but usable
- Provides a canvas of 100 x 50 characters/tiles
- Configure the brush with keyboard (font and back colors, size, ASCII code)
- Fill in the canvas using mouse clicks
- Left click to place tiles with no blocking property (game)
- Left click to place tiles with blocking property (game)
- Toggle between Design and Structure screens
- Load and Save CSV files (format: Xcoord, Ycoord, Fcolor, Bcolor, Block)
- 2 demos included: Haunted and Dungeon
- Unpack on QB64 rott and hit run

Code: QB64: [Select]
  1. 'ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
  2. 'º ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ      ASCII TERRAIN ENGINE     ÛÛßßÛÛ ÛÛßßÛÛ º
  3. 'º ÛÛ     Û     ÛÛ        ® Editor Module ¯      ÛÛ ÞÛÛ ÛÛÛÛÛ  º
  4. 'º ÛÛ  Û  Û  Û  ÛÛ  (to be integreated in v.1.3) ÛÛÜÞÛÛ ÛÛÜÜÛÛ º
  5. 'º    Û  Û  Û        Still rough but usable      ßß          º
  6. 'º ÛÛ  Û  Û  Û  ÛÛ          ------------         ÛÛßßßß ÛÛ  ÛÛ º
  7. 'º ÛÛ  Û     Û  ÛÛ  By Virtusoroca-Brazil, 2020  ÛÛßßÛÛ ÛÛÜÜÛÛ º
  8. 'º ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ          Made in QB64         ÛÛÜÜÛÛ     ÛÛ º
  9. 'ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
  10.  
  11. SCREEN _NEWIMAGE(1000, 800, 256)
  12.  
  13. DIM SHARED KeyPress AS STRING
  14. DIM SHARED ScreenMode AS STRING
  15. DIM SHARED CurrentFontColor AS INTEGER
  16. DIM SHARED CurrentBackColor AS INTEGER
  17. DIM SHARED CurrentASCII AS INTEGER
  18. DIM SHARED CurrentSize AS INTEGER
  19. DIM SHARED FilePath AS STRING
  20. DIM SHARED FileName AS STRING
  21.  
  22.  
  23. TYPE Tiles
  24.     x AS INTEGER
  25.     y AS INTEGER
  26.     a AS INTEGER
  27.     fc AS INTEGER
  28.     bc AS INTEGER
  29.     s AS INTEGER
  30.     b AS INTEGER
  31.  
  32. DIM SHARED Tile(50, 100) AS Tiles
  33.  
  34. CurrentFontColor = 7
  35. CurrentBackColor = 0
  36. CurrentASCII = 219
  37. CurrentBlock = 0
  38. CurrentSize = 1
  39. ScreenMode = "Design"
  40. FilePath = "./ATE_editor_files/"
  41.  
  42. LoadMapDefaut
  43. PrintMapDesign
  44.     KeyPress = UCASE$(INKEY$)
  45.         MouseX = INT(_MOUSEY / 16) + 1: MouseY = INT(_MOUSEX / 8) + 1
  46.         IF MouseX < 0 THEN MouseX = 0
  47.         IF MouseX > 50 THEN MouseX = 50
  48.         IF MouseY < 0 THEN MouseY = 0
  49.         IF MouseY > 100 THEN MouseY = 100
  50.         SELECT CASE _MOUSEBUTTON(1)
  51.             CASE -1
  52.                 FOR A = MouseX TO MouseX + CurrentSize - 1
  53.                     FOR B = MouseY TO MouseY + CurrentSize - 1
  54.                         Tile(A, B).fc = CurrentFontColor
  55.                         Tile(A, B).bc = CurrentBackColor
  56.                         Tile(A, B).a = CurrentASCII
  57.                         Tile(A, B).b = 0
  58.                         LOCATE A, B: COLOR CurrentFontColor, CurrentBackColor: PRINT CHR$(CurrentASCII);
  59.                     NEXT
  60.                 NEXT
  61.         END SELECT
  62.         SELECT CASE _MOUSEBUTTON(2)
  63.             CASE -1
  64.                 FOR A = MouseX TO MouseX + CurrentSize - 1
  65.                     FOR B = MouseY TO MouseY + CurrentSize - 1
  66.                         Tile(A, B).fc = CurrentFontColor
  67.                         Tile(A, B).bc = CurrentBackColor
  68.                         Tile(A, B).a = CurrentASCII
  69.                         Tile(A, B).b = 1
  70.                         LOCATE A, B: COLOR CurrentFontColor, CurrentBackColor: PRINT CHR$(CurrentASCII);
  71.                     NEXT
  72.                 NEXT
  73.         END SELECT
  74.     WEND
  75.     PrintMainMenu
  76.     ProcessOptions
  77. LOOP UNTIL KeyPress = "Q"
  78.  
  79. SUB PrintMainMenu
  80.     COLOR 15, 0: LocalY = 101
  81.     FOR LocalX1 = 1 TO 50: LOCATE LocalX1, LocalY: PRINT "º";: NEXT
  82.     LocalX2 = 1: LocalY2 = 103
  83.     COLOR 15, 0
  84.     LOCATE LocalX2 + 0, LocalY2: PRINT "CURRENT STATUS"
  85.     COLOR 7, 0
  86.     LOCATE LocalX2 + 2, LocalY2: PRINT "ScreenMode: "; ScreenMode
  87.     LOCATE LocalX2 + 3, LocalY2: PRINT "FontColor: "; CurrentFontColor
  88.     LOCATE LocalX2 + 4, LocalY2: PRINT "BackColor: "; CurrentBackColor
  89.     LOCATE LocalX2 + 5, LocalY2: PRINT "Character:  "; CHR$(CurrentASCII)
  90.     LOCATE LocalX2 + 6, LocalY2: PRINT "BrushSize: "; CurrentSize
  91.     LOCATE LocalX2 + 7, LocalY2: PRINT "Preview:    ";: COLOR CurrentFontColor, CurrentBackColor: PRINT CHR$(CurrentASCII);: COLOR 7, 0
  92.     LOCATE LocalX2 + 9, LocalY2: PRINT "File: ";
  93.     IF FileName = "" THEN PRINT "Not Saved" ELSE PRINT FileName
  94.     LOCATE LocalX2 + 35, LocalY2: PRINT "MouseClick = PlaceTile";
  95.     LOCATE LocalX2 + 36, LocalY2: PRINT "LeftClick  = no Block ";
  96.     LOCATE LocalX2 + 37, LocalY2: PRINT "RightClick = w/ Block"
  97.     LOCATE LocalX2 + 39, LocalY2: PRINT "A = AsciiCode";
  98.     LOCATE LocalX2 + 40, LocalY2: PRINT "F = FontColor";
  99.     LOCATE LocalX2 + 41, LocalY2: PRINT "B = BackColor";
  100.     LOCATE LocalX2 + 42, LocalY2: PRINT "Z = BrushSize";
  101.     LOCATE LocalX2 + 43, LocalY2: PRINT "D = DesignScreen";
  102.     LOCATE LocalX2 + 44, LocalY2: PRINT "X = StructureScreen";
  103.     LOCATE LocalX2 + 45, LocalY2: PRINT "N = NewProject";
  104.     LOCATE LocalX2 + 46, LocalY2: PRINT "L = LoadFile";
  105.     LOCATE LocalX2 + 47, LocalY2: PRINT "S = SaveFile";
  106.     LOCATE LocalX2 + 48, LocalY2: PRINT "Q = Quit";
  107.  
  108. SUB ProcessOptions
  109.     LocalX = 13: LocalY = 103: LOCATE LocalX, LocalY: COLOR 7, 0
  110.     SELECT CASE KeyPress
  111.         CASE "A": INPUT "AsciiCode: ", CurrentASCII: CLS: PrintMapDesign
  112.         CASE "F": INPUT "FontColor: ", CurrentFontColor: CLS: PrintMapDesign
  113.         CASE "B": INPUT "BackColor: ", CurrentBackColor: CLS: PrintMapDesign
  114.         CASE "Z": INPUT "BrushSize: ", CurrentSize
  115.         CASE "D": ScreenMode = "Design": PrintMapDesign
  116.         CASE "X": ScreenMode = "Structure": PrintMapStructure
  117.         CASE "N": LoadMapDefaut
  118.         CASE "S": SaveMapFile
  119.         CASE "L": LoadMapFile
  120.     END SELECT
  121.  
  122. SUB PrintMapDesign
  123.     CLS
  124.     FOR A = 1 TO 50
  125.         FOR B = 1 TO 100
  126.             COLOR Tile(A, B).fc, Tile(A, B).bc
  127.             LOCATE Tile(A, B).x, Tile(A, B).y
  128.             PRINT CHR$(Tile(A, B).a);
  129.         NEXT
  130.     NEXT
  131.  
  132. SUB PrintMapStructure
  133.     CLS: COLOR 7, 0
  134.     FOR A = 1 TO 50
  135.         FOR B = 1 TO 100
  136.             SELECT CASE Tile(A, B).b
  137.                 CASE 1
  138.                     LOCATE Tile(A, B).x, Tile(A, B).y
  139.                     PRINT "1"
  140.             END SELECT
  141.         NEXT
  142.     NEXT
  143.  
  144. SUB SaveMapFile
  145.     LOCATE 13, 103: COLOR 7, 0: INPUT "SaveFile: ", FileName
  146.     OPEN FilePath + FileName FOR OUTPUT AS #1
  147.     FOR A = 1 TO 50
  148.         FOR B = 1 TO 100
  149.             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
  150.         NEXT
  151.     NEXT
  152.     CLOSE #1
  153.     CLS: PrintMapDesign
  154.  
  155. SUB LoadMapFile
  156.     LOCATE 13, 103: COLOR 7, 0: INPUT "LoadFile: ", FileName
  157.     OPEN FilePath + FileName FOR INPUT AS #1
  158.     FOR A = 1 TO 50
  159.         FOR B = 1 TO 100
  160.             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
  161.         NEXT
  162.     NEXT
  163.     CLOSE #1
  164.     CLS: PrintMapDesign
  165.  
  166. SUB LoadMapDefaut
  167.     CLS
  168.     FOR A = 1 TO 50
  169.         FOR B = 1 TO 100
  170.             Tile(A, B).x = A
  171.             Tile(A, B).y = B
  172.             Tile(A, B).a = 0
  173.             Tile(A, B).fc = 7
  174.             Tile(A, B).bc = 0
  175.             Tile(A, B).b = 0
  176.         NEXT
  177.     NEXT
  178.  
  179.  
* ATE_Editor.rar (Filesize: 521.81 KB, Downloads: 154)
ATE_editor_Haunted.jpg
* ATE_editor_Haunted.jpg (Filesize: 799.83 KB, Dimensions: 1920x1080, Views: 356)
ATE_Editor_Dungeon.jpg
* ATE_Editor_Dungeon.jpg (Filesize: 476.59 KB, Dimensions: 1920x1080, Views: 305)

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
See? I keep telling you guys. SCREEN 0, the only screen anyone would ever need! Great haunted house, although the colonoscopy results in the second demo lack suficient clarity for a definitive diagnosis. I'll hold back on adding any additional ASCII humor.

I love old school! Thanks for posting this.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
This is good stuff!
In order to understand recursion, one must first understand recursion.

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Really very nice! :)
But my desktop screen is only 1360x768. So, program screen is too big for me.
if (Me.success) {Me.improve()} else {Me.tryAgain()}


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

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Really very nice! :)
But my desktop screen is only 1360x768. So, program screen is too big for me.

What happens if you use Alt+F to full screen it?

Pete

Change your resolution, change your life. desktopappartments.com
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

FellippeHeitor

  • Guest
What happens if you use Alt+F to full screen it?

Pete

Change your resolution, change your life. desktopappartments.com

Alt+Enter

Offline Virtusoroca

  • Newbie
  • Posts: 24
    • View Profile
Hi everyone. Thanks for checking out the code!

First, a quick correction. CSV format of the file holds: Xcoord, Ycoord, Fcolor, Bcolor, ASCII CODE, block property (1=yes). Forgot the ASCII in privious post.

@Pete and @TerryRitchie, thanks for de comments and im glad you enjoyed it! Trying to build a game engine by a "modular" approach. As a QBasic native Im coping with timing events and other things. Hoping to move ahead gradually.

@Ashish and @FellippeHeitor, do you recommend I downgrade the screen size? Maybe its a bit out of standard?

On Discord, !Loudar made some suggestions too. I will improve this code then integrate the hole thing into the ASCII Terrain Engine. Then you will be able to edit your terrain and assets on the fly, as you play them in another screen.

Keep you guys posted. Thanks agian!
Horizonte.jpg
* Horizonte.jpg (Filesize: 135.51 KB, Dimensions: 1014x833, Views: 274)

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
What happens if you use Alt+F to full screen it?
As Fellippe said, you are probably talking about Alt+Enter. Are you currently playing video games? :P

@Virtusoroca As you wish. But, I will surely going to follow Pete's suggestion.
if (Me.success) {Me.improve()} else {Me.tryAgain()}


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

Offline Virtusoroca

  • Newbie
  • Posts: 24
    • View Profile
Thanks @Ashish! I will keep the resolution for now then.

Below, the CSV files of 2 other demos I made: Horizon and BlindFire.

Thinking of a point/click shooter game with that theme.

Going old school, full throtlle! @TerryRitchie @Pete

Hey @OldMoses this might interest you.

This editor is not compatible with the Terrain Engine yet.

But Im planning the next version of the Engine to have this editor as an integrated module.

Thanks again everyone!
* Horizon.txt (Filesize: 79.75 KB, Downloads: 166)
* BlindFire.txt (Filesize: 80.6 KB, Downloads: 160)
BlindFire.jpg
* BlindFire.jpg (Filesize: 74.15 KB, Dimensions: 797x788, Views: 244)
Horizon.jpg
* Horizon.jpg (Filesize: 135.51 KB, Dimensions: 1014x833, Views: 254)
« Last Edit: May 19, 2020, 03:30:07 pm by Virtusoroca »

Marked as best answer by Virtusoroca on June 06, 2020, 05:12:30 pm

Offline Virtusoroca

  • Newbie
  • Posts: 24
    • View Profile
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
* ATE_Editor_v2.rar (Filesize: 789.94 KB, Downloads: 158)
TerrainFromGeneratorZoomOut.jpg
* TerrainFromGeneratorZoomOut.jpg (Filesize: 493.38 KB, Dimensions: 1920x1080, Views: 218)

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Nice work. :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

Offline Virtusoroca

  • Newbie
  • Posts: 24
    • View Profile
Thanks @Ashish! See the attachments: work in progress, defining the pallette. Thinking of a mini game ;D
WorkInProgress.jpg
* WorkInProgress.jpg (Filesize: 290.39 KB, Dimensions: 798x706, Views: 226)

Offline Virtusoroca

  • Newbie
  • Posts: 24
    • View Profile
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)
India_ASCII_16color.jpg
* India_ASCII_16color.jpg (Filesize: 311.69 KB, Dimensions: 797x781, Views: 206)
* India_ASCII_16colors.txt (Filesize: 84.46 KB, Downloads: 152)

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
@Virtusoroca That's very impressive ❤
if (Me.success) {Me.improve()} else {Me.tryAgain()}


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

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
@Virtusoroca That's very impressive ❤

+1

It is artwork! Are you using image converting to Ascii?