I'm seeing a few similar graphic effects that seem to be of use in games. The most of which is having an outline appear around text and to shadow it.
I also saw someone working on a "FILL" routine but it kept crashing because it was recursive.
Here are truly 5-lines of code with one routine to each. Ah, I didn't say how LONG each single line of code was though, did I ? :)
While I have you on the horn, I was hoping someone could submit source for a few useful routines not just for me but likely others:
1. Draw Hollow Oval & Filled Oval
- Draw Polygon & Filled Polygon (w any # of points, not just 3 or 4)
That fill function is a bit odd, and doesn't seem to really work like the bucket tool in a drawing program works.
I use a pretty simple recursive function that is pretty fast and doesn't crash for me at least.
function fill(x,y,to_c) local on_c=pget(x,y) if on_c==to_c then return end function flood(x,y) if pget(x,y)==on_c then pset(x,y,to_c) if (x>0) flood(x-1,y) if (x<127) flood(x+1,y) if (y>0) flood(x,y-1) if (y<127) flood(x,y+1) end end flood(x,y) end
W O W ! Just wow. This can not only do the entire screen without running out of memory, but VERY quickly and efficiently as well !
You are doing something unusual in here too. Is that a function WITHIN a function ? I didn't know you could do that.
My code, I wrote off the cuff years ago by watching how Apple ][ did a fill in for a region for an adventure game.
This recursion coding method you are using is also something pretty new to me. I think I've written all of two recursive programs in my time on computers, and even then I had difficulty wrapping my head around them.
VERY WELL DONE, Cheepicus !
Not now, but with your permission, I'd like to use this for a vector generator - that is, unless, you know code on how to create filled vector points solely ? :)
I've never written polygon or ellipse functions, that might be something to try.
The function-in-a-function trick -- wrapping a recursive function with a shell that does nothing more than invoke the inner function -- is a basic functional programming thing. Nested functions are useful in all kinds of programming though.
Still VERY excellent coding in PICO. Would love to see you make use of this in something. Me ? I have in mind some ideas ... I'll definitely get around to them now that there is a flawless and VERY fast fill routine.
Really very commendable, Cheepicus !
Any other magic up that sleeve ? :) I'm forever amazed and impressed at some of the code I've seen for PICO.
'Tis a shame it is a real PAIN to code in Blitzmax, but unfortunately that is ultimately where I will want to go if I make my own game making programming language - was deciding on 800x600 resolution. Let's see ... it's not complete, you really can't do too much in it yet.
I wanted an infinite UNDO mode and that's what I'm working on ATM.
Try out NUMBER KEYPAD "*" This is where it shines. The screen resolution is 800x600, but in hitting this, it ZOOMS to fill the vertical with matching screen size minus taskbar, hit again and it stretches a comfortable 1.25x horizontal, hit again, and it goes back.
Now imagine writing code for a 800x600 screen that meets or exceeds anyone's monitor needs ? :)
This is one reason I wanted PICO to have the option to expand it's graphics and palette.
Left and right change the polygon sides, Z/O reroll.
Okay here's some polygon drawin' code. It's more of a thing to build upon, rather than a complete polygon package. It's ~423 tokens, including a free quicksort function.
I'm not seeing any problems, Cheepicus. You mentioned it gives trouble with long edges ? I let it run for quite a-while and it seems to just perfect.
Marvelous code ! Were the resolution full (1280x720), you could create some great and large vectored images for video games that had great sharp lines to them.
It should also possible to incorporate your vector routine to create a 3D Raytrace dungeon of sorts.
[Please log in to post a comment]