Playfield Editor that outputs code

Just starting out? Need help? Post your questions and find answers here.
User avatar
Random Terrain
Posts: 63
Joined: Fri Jul 09, 2021 9:48 pm
Location: USA
Contact:

Playfield Editor that outputs code

Post by Random Terrain »

I only know how to use BASIC-like languages, so I hope SpiderBasic is what I've been looking for. I've edited bits of JavaScript code here and there to make it do what I want, but I can't write my own JavaScript programs.

I'd like to make a tool similar to this:

https://alienbill.com/2600/atari-background-builder/

You draw what you want to see in your Atari 2600 game, select background/foreground row colors, and when you are done, it outputs code that looks similar to this:

Code: Select all

   playfield:
   ................................
   ................................
   ................................
   ................................
   .XXXXX.XXXX.XX...XXXX.XXXX.XXXX.
   .XX....XX...XX...XX...XX....XX..
   .XXXXX.XXXX.XX...XXXX.XX....XX..
   ....XX.XX...XX...XX...XX....XX..
   .XXXXX.XXXX.XXXX.XXXX.XXXX..XX..
   ................................
   ................................
   XXXXX.XXXX.XXXX.XXXXX....XX.XX..
   XX....XX...XX...XX..XX..XXXXXXX.
   XXXXX.XXXX.XXXX.XX..XX...XX.XX..
   ...XX.XX...XX...XX..XX..XXXXXXX.
   XXXXX.XXXX.XXXX.XXXXX....XX.XX..
   ................................
   ................................
   ................................
   ................................
   ................................
   ................................
end

   pfcolors:
   $00
   $00
   $00
   $00
   $0E
   $0C
   $0A
   $08
   $06
   $00
   $00
   $0E
   $0C
   $0A
   $08
   $06
   $00
   $00
   $0E
   $0C
   $0A
   $08
   $06
   $00
   $00
   $06
end


   bkcolors:
   $80
   $80
   $80
   $80
   $80
   $80
   $80
   $80
   $80
   $80
   $80
   $80
   $80
   $80
   $80
   $80
   $80
   $80
   $80
   $80
   $80
   $80
end

That's for a batari Basic DPC+ screen that has 22 rows that are 8 scanlines high (for making Atari 2600 games).

Is it possible to make something like that page with SpiderBasic? If so, how do I start? I downloaded the free version of SpiderBasic and if it's possible to make what I want and it isn't too hard for me to do it (with help), I'll buy SpiderBasic and make more online tools.

Thanks.
munfraid
Posts: 104
Joined: Sat Mar 24, 2018 1:33 pm

Re: Playfield Editor that outputs code

Post by munfraid »

Hello and welcom to the forums!

Yes, it's definitly possible to create such an editor with SB, and it's even pretty easy.

Let's try a little programm. First open a window. In this case we prefer the whole browser window as our window. Let's also define a background color:

Code: Select all

OpenWindow(0, 0, 0, 0, 0, "Playfield Editor", #PB_Window_Background)
SetWindowColor(0, #Gray)
Now let's add some text to have a title. We also give it a font and a color:

Code: Select all

TextGadget(0, 30, 30, 300, 30, "Playfield Editor")
LoadFont(0, "Arial", 30) 
SetGadgetFont(0, FontID(0))
SetGadgetColor(0, #PB_Gadget_FrontColor, #White)
Now we get more serious and add some gadgets. We put the playfield and some buttons:

Code: Select all

CanvasGadget(1, 30, 90, 400, 400)
ButtonGadget(2, 460, 90, 180, 30, "A button")
CheckBoxGadget(3, 460, 150, 180, 30, "Checkbox 1")
CheckBoxGadget(4, 460, 190, 180, 30, "Checkbox 2")
ButtonGadget(5, 460, 250, 180, 30, "Another button")
Note: This is a very simplified way to code in SB, just to make the beginning easier to understand. You'll have to dedicate some time to learn a new language, but don't worry, SB it's not difficult. I recommend strongly to study the manual for each command to get more explaination and learn about all the options. Try the examples and play with them. The manual will become your best friend!

Once you understand the first basics as described here, you also should study the examples in the showcase. There you will see how to add functionality to your gadgets, which will be the next step in your programm.

Have fun and success with you editor. Feel free to ask here in the forums for help.
User avatar
Random Terrain
Posts: 63
Joined: Fri Jul 09, 2021 9:48 pm
Location: USA
Contact:

Re: Playfield Editor that outputs code

Post by Random Terrain »

Thanks. That's good to know. And thanks for the links. I hope to learn enough to eventually make at least a few online tools for batari Basic users.
Post Reply