This function uses bresenham's algorithm mirrored to the 8 octants, filtered by angle for the desired arc angles. It's so slow as to be useless; there are much better arc functions on the BBS already. I'm posting it for posterity and future reference, and because it inspired me to come up with a handy octant-range asin() approximation that might actually be useful
-- approximation of asin(d) for 0<=d<=.7071 -- exact at d==0, d==sin(1/16), d==sin(1/8) -- max error .0021 at d==sin(3/32) in given range -- error within that max beyond bounds up to d==sin(.137) function delta2angle(d) return d * 0x.29cf + (d > 0x.61f8 and (d - 0x.61f8) * 0x.0785 or 0) end function arc(x, y, r, a1, a2, ...) a1 %= 1 a2 %= 1 if (a1 == a2) pset(x + r * cos(a1), y - r * sin(a1), ...) return a2 = a2 + (a1 > a2 and 1 or 0) -- ensure a2>a1 dx, dy = r, 0 while dy <= dx do a = delta2angle(dy / r) for flip_x = -1, 1, 2 do for flip_y = -1, 1, 2 do [ [size=16][color=#ffaabb] [ Continue Reading.. ] [/color][/size] ](/bbs/?pid=73025#p) |
We were fiddling with another project and realized that, because we were using sspr() to resize images, we didn't actually know where all the pixels were - and we wanted to know, because we wanted to cast a shadow that was the colors of what was below but in shadow. And we realized that PICO-8 lets you look at the screen in the code, and then the concept of green screen popped into our head, and then we got to work.
It's not minimized and it's not optimized - if you tell it to chromakey the whole screen, it'll chew through the entire CPU budget with change (ask us how we know!) - but I think it's readable enough that people can hack on it. We haven't tested it extensively, but we made sure it respected the current clipping rectangle and restored it before it exited, because that seemed like the correct thing to do.




x,y,w,h=64-10.75,64-10.25,20.5,20.5 rectfill(x,y,x+w-1,y+h-1,8) clip(x,y,w,h) rectfill(x,y,x+w-1,y+h-1,11) circ(64,64,12,12) |

Note that on the top and left the circle extends to the edge of the rect, as is expected since the rect was drawn to match the impending clip region. Note the extra row on the bottom, inside the original rectfill, outside the clipping rectangle.
I think this is a bug. At the very least, it's a place where the documentation needs to be clarified.
(the circle being off center is irrelevant)


Sometimes your cartridge fits in the token count, but not the characters count / compressed size, so you can't export it until you reduce the number of characters in the cartridge. You'd also like to keep comments, meaningful variable names and even debug code where you can, in case you're gonna continue working on the code.
One way to do this is to use a build pipeline:
- copy your source file(s) to an intermediate directory
- process file(s) to reduce code size
- output final cartridge
If you use picotool or work with compiled languages, you should be familiar with that process. It may sound a bit overkill for PICO-8, but is very useful if you're stuck in the case mentioned above.
This is what I do when working with my custom framework pico-boots, but while I don't think many devs would be interested in using a complete framework for PICO-8 written by somebody else, they may be interested in the individual processing steps described below. You can always refer to pico-boots' repository for implementation details.





To see what's been done in Applecart so far, go HERE:
https://www.lexaloffle.com/bbs/?tid=36727
This was supposed to be posted Sunday but I get detained, so here it is Monday. Better late than never, right ? :)
Continuing the Applecart we were going to do five stages of the Apple puzzle game, PENSATE.
- Sprites and game appearance (due now, I finished mine all in just an hour)
- Movement of sprites and player (due 02-09-20)
- Menus and scoring (etc)
- Sound
- Cleanup and completion
For more information about this cart, go HERE:
https://www.lexaloffle.com/bbs/?tid=36727
You should have already completed numbers 1 and 2 over this 2-week period. Here is a video of my version of current PENSATE for Pico-8 based on the original game for the Apple ][.
As you can see like the original you get a chance to choose where to place the player at the bottom for your first move and after that, at least for the first few levels, you get one move for yourself and one move for your opponents.
Explore a bunch of squarish islands, dig up some treasure, leave your footprints!
Experimenting with noise map generation combined with auto-tiling.
Controls:
Arrow keys to move
Z to dig/skip map generator animation
X to show mini-map
Uses @Felice's Noise Map Generator.


Be a dragon! Lay waste to your foes with your claws, bite, and fire breath! Gather gold and bring it back to your lair to grow in power! Bask in the adoration of your kobold followers! (Also you're a circle for some reason. This is Dragondot 3, you should be used to that by now.)
An action-adventure game full of secrets to find and new abilities to gain, drawing inspiration from the Legend of Zelda series among others. Map exploration, skills gained, and hoard stockpiled are all saved persistently, so you can continue your adventure across multiple sessions. Featuring over twenty different types of creatures to encounter, over twenty different skills to acquire (some with multiple upgrade levels), over a hundred map screens to explore (not even counting the dungeons, tunnels, and secret caves!) -- all packed into a single cozy little pico-8 cartridge.










Im not sure what is wrong, but whenever I press Z it never shoots
TAB 0
function _init()
init_objects()
-- set up craft
px=63
py=100
pspr=1
vx=0
thrust=0.1
f=0.97
t_spr=17
-- set up stars
map1y=0
map2y=0
map3y=0
map1_spd=1
map2_spd=0.5
map3_spd=0.25
map_height=128
end
function _update()
--scroll map
map1y+=map1_spd
map2y+=map2_spd
map3y+=map3_spd
if map1y>127 then map1y=0 end
if map2y>127 then map2y=0 end
if map3y>127 then map3y=0 end
-- get input and change sprite
-- and thrust
pspr=1
if btn(0) then
vx-=thrust
pspr=3
end
if btn(1) then
vx+=thrust
pspr=2
end
-- apply thrust and friction
vx*=f
px+=vx
--check edges
if px<0 then
px=0
vx=0
end
if px>120 then
px=120
vx=0
end
-- change thrust sprite
t_spr+=1
if t_spr>19 then t_spr=17 end
--fire bullet
if btn(2) then
add_new_bullet(px,py,0,-3)
end
--draw bullet
for b in all(bullets) do
b:update()
end
end
function _draw()
cls()
-- draw stars
map(0,0,0,map1y,16,16)
map(16,0,0,map2y,16,16)
map(32,0,0,map3y,16,16)
map(0,0,0,map1y-map_height,16,16)
map(16,0,0,map2y-map_height,16,16)
map(32,0,0,map3y-map_height,16,16)
spr(pspr,px,py)
spr(t_spr,px,py+8)
--draw bullet
print(#bullets,1,2)
for b in all(bullets) do
b:draw()
end
end
TAB 1
--objects
function init_objects()
--declare objects
bullets={}
end
function add_new_bullet(_x,_y,_dx,_dy)
add(bullets,{
x=_x,
y=_y,
dx=_dx,
dy=_dy,
life=20,
draw=function(self)
circfill(self.x,self.y,2,11)
end,
update=function(self)
self.x=self.dx
self.y=self.dy
self.life-=1
if self.live<0 then
del(bullets,self)
end
end
})
end



As I'm working rather deeply in coding for the next Sorcery project, I am running into a nasty little thing that when the screen scrolls it jumps back when the cursor is able.
@zep: Suggest using CTRL [ and CTRL ] to shift the viewpoint of the source-code to center it if need be and reset to zero when ENTER is hit.
And before you think my tabs big they are not. I use 2-spaces per indentation so this can visually be a problem with complex and deep level nesting.






So, here's the main thing I've been working on since I posted VVVVVV Moonfall. I've been a lot more relaxed with it, and I've been taking measures to not write total spaghetti code, and some of it's even commented. In all, I'm really proud of how this has been coming together. The camera needs work, as does some little aspects of the movement, and some things need tweaking, but I'll get to all of that eventually.
For now, I've decided to post this mainly because I'm kind of exhausted creatively, and don't really know where to go next. So I'm gonna be taking a break from it, and probably from Pico-8 too. (making carts, at least.) I've been spending almost all of my free time lately on it, and I feel like that's kind of been sucking the life out of me, among other things. Anyway, enough about me.






!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
This is an older work-in-progress version! Play the completed released version here.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
This is a little scaled-sprite 3D graphics engine inspired by the old classic game Power Drift.
Still work in progress. Needs some basic game-play rules (laps, win/lose etc) and some difficulty balancing. But it's playable.










Hello there!
I'm making a Tetris clone that uses the map to save tile data. The program draws the tetraminoes using 2 'for' loops and a table that has start and center information, but also how many columns and rows to draw in this config:
table_x={startx,starty, row1x,row1y,n row1, row2x,row2y,n row2}
The program is supposed to check if it has a second row:
if(table[6]!=nil) then
pos_x,pos_y=0,0
for n=1,table[8],1 do
rot_x,rot_y=rot(table[6]+pos_x,table[7]+pos_y)
for v=0,7,7 do
for b=0,7,7 do
if(op=="gravity") then
flag=fget(mget((p1.x+rot_x+b)/8,(p1.y+rot_y+v)/8),0)
if(flag) then
....


