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 - Abacus

Pages: [1]
1
@Cobalt I would like to have two edit modes. One to make maps that will export a .bi file of DATA statements and the other mode to make tiles/sprites and that will export as a .bsv file. If a tile or sprite needs a mask file that too will export a mask .bsv  file. I like your suggestions, thanks for sharing them!

2
Quote
Hey just what I suggested in Reply #3 of this thread :)

Great minds think alike.

To elaborate more of that reply, you can save the strings for many arrays into single file and more importantly load and save from an array of strings.

The next thing you might want to think about is names for tiles and names for strings, it's easier to do things by name than by number. So maybe another array to translate tile name to tile number or vice versa, and another array to translate sprite array name to number and back.

Then if you want different sized sprites, maybe even some not square you can save width and height with names.
Some more things to think ahead about :)

@bplus  Thank you so much for your kind words and sharing your thoughts with me; I am grateful and agree!

Still, don't worry...my first full version program will use better naming for my variables, arrays, strings, and such. I will add comments and error checking code. All the code I shared were just test samples and to add with not being shy, I would like to share in my old school way on things.

Well, I start with pen and paper before I even write any code or touch a computer.

Here is an image example of my Map Edit mode concept for this program in thought on paper without any code...although code was in mind when I wrote this chart down.

I think it's important to record your thoughts on paper when there is free time and there is no computer around. I do that on a lot of test code ideas and I even did that on the last test code with the MID$() function posted in this thread.

Again, thank you so much for your thoughts and suggestions! I will keep your suggestions and all of the suggestions from others in mind during this thread until my project and goal is complete.

(Peace and Respect)

Mike aka Abacus

3
This is a little off topic on my project, but I wanted to share. Years ago, I wrote a program for a GUI template. During that time in QBASIC to make a box and fill it in with the very basic drawing graphic statements you would use drawing statements such as LINE for drawing the lines for a box and you had to use PSET to fill in the box with a color.

There was no simple box fill (BF) in the DOS version of QBASIC for the LINE statement I used during that time. Here is a screen shot of what I made with those basic draw statements with LINE. I even made the letters in this GUI using LINE. I hope to show you can build any idea you have in mind, even if the graphics are with the so called primitive graphic statements such as LINE in mind. I will add there is no mouse action in this program. Each highlighted letter made a pop down or pop up box for options when you used the keyboard to hit that letter.

Example: If you had hit the N that is in underline, it would pop up a box just like it would do in Windows. Each highlighted letter would do the same such as the O for Options to pop down a box...etc. Each box could be filled with options and commands as it was a template.

Note: The gui.bas file was lost, but I still have the .exe build from the QBASIC 4.5 (full version) for the GUI project I built. I could rebuild it again from my programming notes or wing it. The point I am trying to make is...you can build anything you have in mind for your program even if there are limitations. So, if you think, I can't build an IDE/GUI interface graphically with just the basic draw statements such as LINE...etc. Well, you can.

Huh, after thinking about it...maybe after this Old School Tile/Map project....I will use this GUI.EXE for an example on how to reverse engineer code using a hex editor and some basic assembly tools. I lost the .bas and the program was made by me, so why not? LOL!

Thanks for viewing! (^_^)
 

4
@bplus Thanks for the links! It will be something for me to look over with respect to @191Brian on the subject and others that wish to chime in on the discussion for this project. I would like to add my project is not an absolute way for whatever in code or games I show to build from it. I hope in the end, that stays true and clear in this project  (^_^).

5
@bplus Well, like I said in messages...it's been awhile since I played around with QBASIC and QB64 has brought me the joy to play with it again. I think so far choosing this project in an old school fashion has brought me much joy on building it thus far. I hope by keeping this post alive it will show the process of one concept building to the next for a final design and allow other people struggling with programming in any language to think about each challenge as small parts and will find a solution for each part until the final visualization of the project in mind is complete.

@191Brian thanks for sharing, I will check it out! I should add though....I am doing READ/DATA in this old fashion way for a challenge on this project for myself. I will though, not use Assembly for mouse such as int 33h for the mouse interrupt unless it is requested. I have my goal and vision set on this project. Thank you so much for sharing your info and I will for sure check it out!

6
Well, I made it clear there will be changes for my test code on this project. I never plan to use that many arrays for this project, but it got the ball rolling. Last night, I made a quick test program to use the MID$() function and the concept will reduce the a1$(10)...a2$(10)...a3$(10)...etc down to one array. I like to share this very raw concept change on this project with you guys/gals now.

Code: QB64: [Select]
  1. Dim datnum$(5)
  2. Dim tile_num$
  3. Dim dat_name$
  4. Dim num%
  5.  
  6. datnum$(1) = "0,0,0,0,0"
  7. dat_name$ = "DATA "
  8. tile_num$ = "0"
  9. num% = 0
  10.  
  11. Print dat_name$; datnum$(1) 'Print before change
  12.  
  13. 'Use MID$() to make change
  14. tile_num$ = "5"
  15. num% = 3
  16.  
  17. Mid$(datnum$(1), num%) = tile_num$
  18.  
  19. Print dat_name$; datnum$(1) 'Print after change
  20.  
  21. 'Write info to a file
  22.  
  23. 'open a file for output
  24. Open "mid_test.bi" For Output As #1
  25. Print #1, dat_name$; datnum$(1) 'Write to file after change
  26.  

Thanks for viewing!

7
@bplus I'll edit and make the new correction.

8
@bplus and I had a fun conversation in messages. I shared a program example that lends to the old way in QBASIC and explains a little more of why I posted the example code for my Tile Editor project. @bplus felt we should share these code examples and I agreed. So, here are the code examples. I hope people that don't know about this find it interesting or helpful.

----------------------
Messages
----------------------

------------------------------------
Well, I did a test and it worked.

This part is in a bi file called test.bi

Code: QB64: [Select]
  1.  
  2. Data 0,0,1,0,0
  3. Data 0,0,1,0,0
  4. Data 1,1,1,1,1
  5. Data 0,0,1,0,0
  6. Data 0,0,1,0,0
  7.  


Here is a test program that used the DATA statement in the .bi file and saves the graphic to a binary image file.

Code: QB64: [Select]
  1.  
  2. '$INCLUDE: 'test.bi'
  3.  
  4. 'put sprite information onscreen for capture
  5. For y = 1 To 5: For x = 1 To 5
  6.         Read icolor%: PSet (x, y), icolor%
  7. Next x: Next y
  8. 'capture the sprite
  9. Dim sprite%(25)
  10. Get (1, 1)-(5, 5), sprite%() 'tile now captured in sprite% array
  11. Def Seg = VarSeg(sprite%(0))
  12. BSave "sprite.bsv", VarPtr(sprite%(0)), 25
  13.  
  14.  
  15. 'cover the screen with the tile image
  16. For x = 0 To 319 Step 5: For y = 0 To 199 Step 5
  17.         Put (x, y), sprite%()
  18. Next y: Next x
  19.  


I think in my tile editor I will use both save methods. A save to Data statements for a map and a save for tiles or sprites.

Have a good day!

--------------------------------------
Hi Mike,

Finally got some time to play with your code. It works for me but took me awhile to find where sprite file went (in QB64.exe folder).

I have two more Methods to do same thing for your consideration.

First a modified .bi file, same design different colors for my own tests of screen 12 capabilities:

Code: QB64: [Select]
  1. sprite:
  2. Data 12,12,9,12,12
  3. Data 12,12,9,12,12
  4. Data 14,14,14,14,14
  5. Data 12,12,9,12,12
  6. Data 12,12,9,12,12
  7.  

notice the sprite: line label, this is what I was really curious about to see if RESTORE will work in the .BI file, apparently it works fine.

Here is the bas source for redrawing sprite right from BI, over and over again using a SUB.
That is Method 1 and I admit kind of crude and inefficient. I just wanted to see if it would work.

The 2nd is the modern way to create and capture an image and use over and over as demo'd here:

Code: QB64: [Select]
  1. _Title "Test sprite bi, press any key for 2 methods of sprite display " 'b+ 2021-05-10
  2.  
  3.  
  4. '$include: 'sprite.bi'
  5.  
  6. '  Method 1
  7. 'cover the screen with the tile image
  8. For x = 0 To 639 Step 5: For y = 0 To 479 Step 5
  9.         drawSprite x, y
  10. Next y: Next x
  11.  
  12. ' Method 2 of sprite drawing: draw one, capture in container spriteImg handle,
  13. '  use _putimage (x, y), spriteImg, 0    ' x, y top left corner of rectangle to place image
  14. ' to put anywhere on screen we want 0 is the handle for the screen
  15.  
  16. ' setup to contain sprite image
  17.  
  18. Dim spriteImg As Long  ' sprite handle
  19.  
  20. spriteImg = _NewImage(5, 5, 12)  ' container size and color pallette  12 is like Screen 12's
  21.  
  22. drawSprite 0, 0 ' use first method to draw one sprite in upper left corner
  23. _PutImage , 0, spriteImg, (0, 0)-(4, 4) ' capture image in a spriteImg container
  24. '           (0, 0)-(4, 4) is the source on screen rectangle that we just drew one of                  
  25. For x = 320 To 639 Step 5: For y = 240 To 479 Step 5 ' fill bottom right corner
  26.         _PutImage (x, y), spriteImg ' now place image any where on screen
  27. Next y: Next x
  28.  
  29. '  Sub for Method 1  reads bi file and draws image every time its called
  30. Sub drawSprite (x As Integer, y As Integer)
  31.     Restore sprite ' <<<<<<<<<<<<<<<<<<<<<<<<<<<< here is what I wanted to test from Bi
  32.     For yy = 0 To 4
  33.         For xx = 0 To 4
  34.             Read icolor%: PSet (xx + x, yy + y), icolor%
  35.         Next
  36.     Next
  37.  


The first screen full is drawing from BI file over and over until filled.
press any key

The second screen fills the bottom right corner screen with the image with spriteImg handle
press key again and done.

Mike with your permission I'd like to post these two codes of ours on forum so people might learn past and present ways.

What do you think?

-----------------------------------

So, that was pretty much what we discussed and I will add this last bit of code that shows how to load the sprite.bsv file.

Code: QB64: [Select]
  1.  
  2. DIM sprite%(25)
  3. DEF SEG = VARSEG(sprite%(0))
  4. BLOAD "sprite.bsv", VARPTR(sprite%(0))
  5. FOR x = 0 TO 319 STEP 5
  6.     FOR y = 0 TO 199 STEP 5
  7.         PUT (x, y), sprite%()
  8.     NEXT y
  9.  
  10.  

Well, that's about it for today.

Thanks for viewing!

9
Very cool!

10
@bplus  That takes me back to my BBS and DOS 6.22 days working on a 9600 baud modem and sending an image in that format. I will for sure keep your recommendation in mind.

Thank you!!!

Much love and respect!

11
Thanks @bplus

Cool! I can dig that understanding for sure all the way. I have messed with some assembly code and binary file formats and such. I just want to build this Tile editor with READ/DATA in mind at a very beginner level. I welcome your feedback and support. Thank you for responding to my post as well. It makes me happy! :)

12
I'm sitting at work and doing some Old School programming in a new version QBASIC called QB64. I wrote this test program to save a 6x10 grid of DATA statements to a file. The reason I made this test program because I later will make a Graphical Tile Editor. The Tile Editor will be very basic and will help me build this Old School style RPG game in QB64 using READ/DATA statements.

The main problem I faced was when using READ/DATA in QB64 or QBASIC, the data could not be changed in the DATA statements. Therefor, I wrote this test program to get around that problem.

The test was successful and can move on to make the Tile Editor. This will allow me to not type out large DATA statements by hand. Instead, I will be able to use a mouse to pick a color square and fill it on a grid to build a map.  I can then export a file of DATA statements to import into the game project.

Sure, I could do this in a different program language such as C/C++ or use a powerful game engine to build a game easier...still, that takes way the fun challenge to do this all in QB64/QBASIC.

So, I wanted to share a screen shot of my test program.

I will share the test code...although, there will be lots of changes on this programming adventure!

Code: QB64: [Select]
  1. 'This program creates a 6x10 grid of numbers with the word DATA
  2. 'in front of each line. The program then saves the 6x10 grid to
  3. 'a file called map_test.bi. The reason for this test program is
  4. 'so that I can later build a graphical editor for tile based games.
  5. 'The games will use READ/DATA statements and the DATA in a READ/
  6. 'DATA statement can't be changed. That lead to creating this pro-
  7. 'gram. The exported file can be added to the game project and
  8. 'the user will not have to type large DATA statements; instead,
  9. 'with the graphical interface they will be able to layout color
  10. 'squarse using the mouse in the grid. Example: A green squre will
  11. 'be for grass...ie., etc.
  12. '
  13. 'By: Abacus 5/8/2021
  14.  
  15.  
  16. 'declare some arrays
  17. Dim a1$(10)
  18. Dim a2$(10)
  19. Dim a3$(10)
  20. Dim a4$(10)
  21. Dim a5$(10)
  22. Dim a6$(10)
  23.  
  24.  
  25. 'this will be used to place the word DATA in front
  26. name$ = "DATA"
  27.  
  28. 'loading the arrays with numerical valuse for the grid
  29. a1$(1) = "1": a2$(1) = "2": a3$(1) = "0": a4$(1) = "0": a5$(1) = "0": a6$(1) = "0":
  30. a1$(2) = "0": a2$(2) = "0": a3$(2) = "3": a4$(2) = "0": a5$(2) = "0": a6$(2) = "1":
  31. a1$(3) = "1": a2$(3) = "0": a3$(3) = "0": a4$(3) = "0": a5$(3) = "0": a6$(3) = "0":
  32. a1$(4) = "0": a2$(4) = "0": a3$(4) = "0": a4$(4) = "0": a5$(4) = "0": a6$(4) = "0":
  33. a1$(5) = "0": a2$(5) = "0": a3$(5) = "0": a4$(5) = "0": a5$(5) = "0": a6$(5) = "2":
  34. a1$(6) = "0": a2$(6) = "0": a3$(6) = "0": a4$(6) = "5": a5$(6) = "0": a6$(6) = "0":
  35. a1$(7) = "0": a2$(7) = "0": a3$(7) = "0": a4$(7) = "0": a5$(7) = "0": a6$(7) = "0":
  36. a1$(8) = "0": a2$(8) = "0": a3$(8) = "0": a4$(8) = "0": a5$(8) = "0": a6$(8) = "0":
  37. a1$(9) = "0": a2$(9) = "0": a3$(9) = "0": a4$(9) = "0": a5$(9) = "0": a6$(9) = "0":
  38. a1$(10) = "0": a2$(10) = "0": a3$(10) = "0": a4$(10) = "0": a5$(10) = "0": a6$(10) = "0":
  39.  
  40. 'explains what the program is doing
  41. Print " This program displays a 6x10 grid of DATA statments and"
  42. Print " will write this information to a file named map_test.bi"
  43. Print " Hit the Spcaebar to start."
  44. 'wait for keypress
  45.  
  46. 'a loop to print all the numbers out correctly in the grid format
  47. For clr = 1 To 10
  48.  
  49.     Print name$; " "; a1$(clr); ","; a2$(clr); ","; a3$(clr); ",";
  50.     Print a4$(clr); ","; a5$(clr); ","; a6$(clr)
  51. Next clr
  52.  
  53. 'tells that the file is being saved
  54. Print "Saving to file..."
  55.  
  56.  
  57. 'open a file for output
  58. Open "map_test.bi" For Output As #1
  59.  
  60. 'a loop to save the grid to a file in the correct format
  61. For clr = 1 To 10
  62.     Print #1, name$; " "; a1$(clr); ","; a2$(clr); ","; a3$(clr); ",";
  63.     Print #1, a4$(clr); ","; a5$(clr); ","; a6$(clr)
  64. Next clr
  65.  
  66. 'close file
  67.  
  68. 'tells that the file is saved
  69. Print "Save complete!": Sleep 1: Print: Print "Goodbye!": Sleep 1
  70.  
  71.  
  72. 'end of program
  73.  
  74.  

Pages: [1]