Log In  

BBS > Superblog
Posts: All | Following    GIFs: All | Postcarts    Off-site: Accounts

In my game, bullets have in different sizes. I want to use a sprite for the bullet but don't want to make a sprite for each possible size because it will vary (or be random).

I'm hoping there is a way to scale/enlarge/shrink a sprite so I can just make one sprite and use it lots of places.

8 comments


Cart #20909 | 2016-05-20 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

Hi there,
just a little intro done while testing PICO-8.

Playing with sfx give me the basic tone of the music from the game "Prohibition" on Amstrad CPC (the 16-bit versions had another music). So I translate by hear/memory the beginning of the song.

Enjoy :p

2
0 comments


If you'd like to take part in P8JAM2, please select one or more themes by clicking on the PICO-8 star next to it (you need to be logged in). You can change it anytime before the 24h voting phase ends -- at 00:00 PST on Saturday the 21st. Check out the jam thread for more details.

Edit: times's up! The winning theme is Chain Reaction. You have 9 days! Good luck!

11
40 comments


Cart #20875 | 2016-05-20 | Code ▽ | Embed ▽ | No License

Sat down for my first hour of learning both LUA and Pico-8.

This was just to practice parts of the software and get things up on the screen.
Also to test out saving and uploading a cart.

Next I plan to:

  • Research the best way to handle multiple moving objects.
  • Add controls
  • Add weapons
  • Detect collisions
  • Game states (start, win, lose)
0 comments


Cart #20870 | 2016-05-19 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

This is a work in progress tool, which currently allow you to look at the Pico-8 memory content.
It's really crude but do it's job:

Left will substract 0x10 to the current address, Right will add 0x100, UP will remove 0x100, Down add 0x100.

The display is in three parts, the top that show the top address, the middle with alternating bluish/pink that show a gris of 16*16 bytes from memory starting from address, and the value are show in Hexadecimal

The bottom part show the first half of the same memory as in hexadecimal, but will display the values as character and not hex, useful to look for string!

2
0 comments


Hi ZEP,

I'm going to make a Pico-8 stand for a retrogaming convention later this year, and I was thinking on how to organise it.
And I would really want to use Splore as the browser for existing cart, especially because it works really well in my arcade cabinet.
But as you know apart from the "local folder" tab, Splore can only be used when the computer is online and have access to your website.

As Pico-8 is, I think, using standard web services for Splore, it would be nice if the base URL could be changed in the config, instead of using fake DNS, for such a (unusual) use.
But that would also mean that the BBS protocol should be documented in a way too.

My idea for the stand is to have multiple devices connected together on a network (wired/wireless doesn't matter), so I can have access to all the computer (which will mostly be rPi and probably my CHIP) so they could share data, and as Splore is a really good browser for that, it would be really nice to have access to it.

By the way, it would be nice too to have a way to directly push a new cart from Pico-8 and not have to rely on the web browser, but that's another problem.
As my goal is really to try to make the cluster of Pico-8 to be autonomous from the internet, this functionality will allow me to let people share their production on all the pico8 available using the offline bbs, without the need of having a web browser running on the Pi.
Especially as I will want to make it run Pico-8 directly and to not have access to anything else, like if it was a real console hardware.

I think I may add more about this project on my "blog" part here with the advancement of this project as I want it to be useful for other people making event around Pico-8

Cheers

1
2 comments


Cart #20859 | 2016-05-19 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

I've been working on a tile based puzzle game recently and to make things easy initially I setup random generating levels. While this helped me get through adding and testing the mechanics and my code I realised that some times in testing I'd get a level I might want to play again but as it was one of eight million I wasn't likely to generate it again.

So I realised that I would need to create Level IDs and a system for inputting them. This is my first attempt at a very basic input and the screen displays the output too that I would feed into some variables in my game to get back to that challenging level.

As a complete novice any feedback or improvements are greatly appreciated. My known bugs so far are not knowing a slick method to stop the highlight moving off either end of the row and not being able to limit the range of letters (you can go down from A etc.)

--basic levelid i/o
--by lorcav

function _init()
cls()
hlight={}
hlight.x=32
hlspr=29
l1=1
l2=1
l3=1
l4=1
l5=1
l6=1
l7=1
actsprpos=1
end

function _update()
cls()
map (0,0,0,0,16,8)
move(hlight)
spr(hlspr,hlight.x,40)
spr(30,hlight.x,24)
spr(l1,32,32)
spr(l2,40,32)
spr(l3,48,32)
spr(l4,56,32)
spr(l5,64,32)
spr(l6,72,32)
spr(l7,80,32)
movebound()
end

function move()
if(btnp(0)) --left
  then
 hlight.x-=8
 actsprpos-=1
 end
if(btnp(1))--right
 then
  hlight.x+=8
  actsprpos+=1
 end
if(btnp(2))--up
 then
 entryup()
 end
if(btnp(3))--down
 then
 entrydown()
 end
if(btnp(4))--confirm
 then
 end
end

function entryup()
if actsprpos==1
 then l1+=1
end
if actsprpos==2
 then l2+=1
end

if actsprpos==3
 then l3+=1
end

if actsprpos==4
 then l4+=1
end

if actsprpos==5
 then l5+=1
end

if actsprpos==6
 then l6+=1
end

if actsprpos==7
 then l7+=1
end
end

function entrydown()
if actsprpos==1
 then l1-=1
end
if actsprpos==2
 then l2-=1
end

if actsprpos==3
 then l3-=1
end

if actsprpos==4
 then l4-=1
end

if actsprpos==5
 then l5-=1
end

if actsprpos==6
 then l6-=1
end

if actsprpos==7
 then l7-=1
end
end

function movebound()
if hlight.x>=81 then
   hlight.x=32
   actsprpos=1
end
if hlight.x<=31 then
   hlight.x=80
   actsprpos=7
end
if l1>=14 then  l1=1
end
end

function _draw()
print ("please enter level id",19,44,10)
print (l1,35,52,8)
print (l2,43,52,8)
print (l3,51,52,8)
print (l4,59,52,8)
print (l5,67,52,8)
print (l6,75,52,8)
print (l7,83,52,8)
end
1 comment


Cart #tenkizoti-4 | 2020-04-10 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
119

Hi Aviator!

This is a tiny flight simulator based on a Cessna-172R with a G1000 glass cockpit. (This is the plane I fly in real life, so I thought it would be a challenge to see if it can be done with Pico-8.)

The flight model is not based on theory but on my observations as a pilot. I have to say that it's quite good ;-) Within the limits of Pico-8 it quite feels like the real thing.

Disclaimer: while I created the instruments and the flight model, the majority of the programming work was done by @freds72, including 3D outside view, code structure, eye candy, music, etc. Many thanks Fred, this would not have been possible without your ninja programming skills!!

[ Continue Reading.. ]

119
34 comments


Pico lacks native stack and queue support. I'm unhappy about it, so i cried a bit and my friend GreyKnight came up with a small implementation of a deque (queue/stack combo). From preliminary tests it works fine.

-- 3 tokens
push=add

-- 19 tokens
function pop(stack)
    local v = stack[#stack]
    stack[#stack]=nil
    return v
end

-- 11 tokens
function pop_discard(stack)
    stack[#stack]=nil
end

-- 3 tokens
enqueue=add

-- 16 tokens
function dequeue(queue)
    local v = queue[1]
    del(queue, v)
    return v
end

----- Usage -----
stack = {}
push(stack, "goat")
push(stack, "billy")
assert("billy" == pop(stack))
assert("goat" == pop(stack))

queue = {}
enqueue(queue, "nanny")
enqueue(queue, "kid")
assert("nanny" == dequeue(queue))
assert("kid" == dequeue(queue))

[ Continue Reading.. ]

4
2 comments


[sorry if you have seen this already. I have no idea which posts show up where in this bbs and I keep on putting it in the wrong places]
I'm kind of working on a couple of shameful hacks for Pico.
The first one is a network stack. Since Hey @ lexaloffe is not answering my emails, I'm just keeping myself busy this way :p. I have a few ways I can try, including saving and reading from a cartridge that, in fact, is a named pipe. More on that later.
The second hack is an on-screen keypad. Android users can't use pico as the keyboard does not pop up. So I made a thingie. This is what it looks like on my desktop while I play PICO-2048:

So save this bookmarklet and use it in a cartridge page: [PICOPAD](javascript:(function()%7Bfunction%20insertAfter(referenceNode%2C%20newNode)%20%7BreferenceNode.parentNode.insertBefore(newNode%2C%20referenceNode.nextSibling)%3B%7Dfunction%20lp_key_event(letter%2C%20code%2C%20type)%7Bvar%20e%20%3D%20new%20Event(type)%3Be.key%3Dletter%3Be.keyCode%3Dcode%3Be.which%3De.keyCode%3Be.altKey%3Dfalse%3Be.ctrlKey%3Dtrue%3Be.shiftKey%3Dfalse%3Be.metaKey%3Dfalse%3Be.bubbles%3Dtrue%3Breturn%20e%3B%7Dwindow.pressZ%20%3D%20function()%7B%20%20%20%20%20%20document.dispatchEvent(lp_key_event(%22Z%22%2C%22Z%22.charCodeAt(0)%2C%22keydown%22))%3B%20%7D%3Bwindow.pressX%3D%20function()%7B%20%20%20%20%20%20document.dispatchEvent(lp_key_event(%22X%22%2C%22X%22.charCodeAt(0)%2C%22keydown%22))%3B%20%7D%3Bwindow.pressLeft%3D%20function()%7B%20%20%20document.dispatchEvent(lp_key_event(%22%22%2C37%2C%22keydown%22))%3B%20%7D%3Bwindow.pressUp%3D%20function()%7B%20%20%20%20%20document.dispatchEvent(lp_key_event(%22%22%2C38%2C%22keydown%22))%3B%20%7D%3Bwindow.pressRight%3D%20function()%7B%20%20document.dispatchEvent(lp_key_event(%22%22%2C39%2C%22keydown%22))%3B%20%7D%3Bwindow.pressDown%3D%20function()%7B%20%20%20document.dispatchEvent(lp_key_event(%22%22%2C40%2C%22keydown%22))%3B%20%7D%3Bwindow.releaseZ%3D%20function()%7B%20%20%20%20%20%20document.dispatchEvent(lp_key_event(%22Z%22%2C%22Z%22.charCodeAt(0)%2C%22keyup%22))%3B%20%7D%3Bwindow.releaseX%3D%20function()%7B%20%20%20%20%20%20document.dispatchEvent(lp_key_event(%22X%22%2C%22X%22.charCodeAt(0)%2C%22keyup%22))%3B%20%7D%3Bwindow.releaseLeft%3D%20function()%7B%20%20%20document.dispatchEvent(lp_key_event(%22%22%2C37%2C%22keyup%22))%3B%20%7D%3Bwindow.releaseUp%3D%20function()%7B%20%20%20%20%20document.dispatchEvent(lp_key_event(%22%22%2C38%2C%22keyup%22))%3B%20%7D%3Bwindow.releaseRight%3D%20function()%7B%20%20document.dispatchEvent(lp_key_event(%22%22%2C39%2C%22keyup%22))%3B%20%7D%3Bwindow.releaseDown%3D%20function()%7B%20%20%20document.dispatchEvent(lp_key_event(%22%22%2C40%2C%22keyup%22))%3B%20%7D%3Bvar%20el%20%3D%20document.createElement(%22div%22)%3Bel.innerHTML%20%3D%20%22%3Cdiv%3E%22%2B%22%3Cdiv%20style%3D%5C%22display%3Ainline-block%3B%5C%22%3E%22%2B%22%3Cdiv%20style%3D%5C%22width%3A100px%3B%20height%3A100px%3B%20%5C%22%3E%26nbsp%3B%3C%2Fdiv%3E%22%2B%22%3Cdiv%20style%3D%5C%22width%3A100px%3B%20height%3A100px%3B%20background%3Ared%3B%5C%22%20onMouseDown%3D%5C%22window.pressLeft()%5C%22%20onMouseUp%3D%5C%22window.releaseLeft()%5C%22%20ontouchstart%3D%5C%22window.pressLeft()%5C%22%20ontouchend%3D%5C%22window.releaseLeft()%5C%22%3E%20%26nbsp%3B%3C%2Fdiv%3E%22%2B%22%3Cdiv%20style%3D%5C%22width%3A100px%3B%20height%3A100px%3B%20%5C%22%3E%26nbsp%3B%3C%2Fdiv%3E%22%2B%22%3C%2Fdiv%3E%22%2B%22%3Cdiv%20style%3D%5C%22display%3Ainline-block%3B%5C%22%3E%22%2B%22%3Cdiv%20style%3D%5C%22width%3A100px%3B%20height%3A100px%3B%20background%3Agreen%3B%5C%22%20onMouseDown%3D%5C%22window.pressUp()%5C%22%20onMouseUp%3D%5C%22window.releaseUp()%5C%22%20ontouchstart%3D%5C%22window.pressUp()%5C%22%20ontouchend%3D%5C%22window.releaseUp()%5C%22%3E%26nbsp%3B%3C%2Fdiv%3E%22%2B%22%3Cdiv%20style%3D%5C%22width%3A100px%3B%20height%3A100px%3B%20%5C%22%3E%26nbsp%3B%3C%2Fdiv%3E%22%2B%22%3Cdiv%20style%3D%5C%22width%3A100px%3B%20height%3A100px%3B%20background%3Ablue%3B%5C%22%20onMouseDown%3D%5C%22window.pressDown()%5C%22%20onMouseUp%3D%5C%22window.releaseDown()%5C%22%20ontouchstart%3D%5C%22window.pressDown()%5C%22%20ontouchend%3D%5C%22window.releaseDown()%5C%22%3E%20%26nbsp%3B%3C%2Fdiv%3E%22%2B%22%3C%2Fdiv%3E%22%2B%22%3Cdiv%20style%3D%5C%22display%3Ainline-block%3B%5C%22%3E%22%2B%22%3Cdiv%20style%3D%5C%22width%3A100px%3B%20height%3A100px%3B%20%5C%22%3E%26nbsp%3B%3C%2Fdiv%3E%22%2B%22%3Cdiv%20style%3D%5C%22width%3A100px%3B%20height%3A100px%3B%20background%3Ared%3B%5C%22%20onMouseDown%3D%5C%22window.pressRight()%5C%22%20onMouseUp%3D%5C%22window.releaseRight()%5C%22%20ontouchstart%3D%5C%22window.pressRight()%5C%22%20ontouchend%3D%5C%22window.releaseRight()%5C%22%3E%20%26nbsp%3B%3C%2Fdiv%3E%22%2B%22%3Cdiv%20style%3D%5C%22width%3A100px%3B%20height%3A100px%3B%20%5C%22%3E%26nbsp%3B%3C%2Fdiv%3E%22%2B%22%3C%2Fdiv%3E%22%2B%22%3Cdiv%20style%3D%5C%22display%3Ainline-block%3B%5C%22%3E%22%2B%22%3Cdiv%20style%3D%5C%22width%3A100px%3B%20height%3A100px%3B%20%5C%22%3E%26nbsp%3B%3C%2Fdiv%3E%22%2B%22%3C%2Fdiv%3E%22%2B%22%3Cdiv%20style%3D%5C%22display%3Ainline-block%3B%5C%22%3E%22%2B%22%3Cdiv%20style%3D%5C%22width%3A100px%3B%20height%3A100px%3B%20%5C%22%3E%26nbsp%3B%3C%2Fdiv%3E%22%2B%22%3Cdiv%20style%3D%5C%22width%3A100px%3B%20height%3A100px%3B%20background%3Ared%3B%5C%22%20onMouseDown%3D%5C%22window.pressZ()%5C%22%20onMouseUp%3D%5C%22window.releaseZ()%5C%22%20ontouchstart%3D%5C%22window.pressZ()%5C%22%20ontouchend%3D%5C%22window.releaseZ()%5C%22%3E%26nbsp%3B%3C%2Fdiv%3E%22%2B%22%3Cdiv%20style%3D%5C%22width%3A100px%3B%20height%3A100px%3B%20%5C%22%3E%26nbsp%3B%3C%2Fdiv%3E%22%2B%22%3C%2Fdiv%3E%22%2B%22%3Cdiv%20style%3D%5C%22display%3Ainline-block%3B%5C%22%3E%22%2B%22%3Cdiv%20style%3D%5C%22width%3A100px%3B%20height%3A100px%3B%20%5C%22%3E%26nbsp%3B%3C%2Fdiv%3E%22%2B%22%3Cdiv%20style%3D%5C%22width%3A100px%3B%20height%3A100px%3B%20background%3Ablue%3B%5C%22%20onMouseDown%3D%5C%22window.pressX()%5C%22%20onMouseUp%3D%5C%22window.releaseX()%5C%22%20ontouchstart%3D%5C%22window.pressX()%5C%22%20ontouchend%3D%5C%22window.releaseX()%5C%22%3E%26nbsp%3B%3C%2Fdiv%3E%22%2B%22%3Cdiv%20style%3D%5C%22width%3A100px%3B%20height%3A100px%3B%20%5C%22%3E%26nbsp%3B%3C%2Fdiv%3E%22%2B%22%3C%2Fdiv%3E%22%3BinsertAfter(document.getElementById(%22canvas%22)%20%7C%7C%20document.getElementById(%22playarea_0%22)%2C%20el)%7D)())

[ Continue Reading.. ]

6
12 comments


Hi!

I have just started to learn game development. My only programming experience comes from making few simple things in BASIC more than 15 years ago, but when I found PICO-8 (thanks to the C.H.I.P Kickstarter) I felt a nostalgic pull and decided to jump in into this whole gamedev thing.

I have started a blog: Level0GameDeveloper where I document this journey and explain everything what I am doing, so maybe someone like me (who doesn't have an idea where to start with this whole game making thing) will find it helpful and will also give it a try (maybe even with PICO-8?!).

Anyway, I was hoping that you guys could give me some pointers, as many of you are, what I would consider, amazing programmers (I have seen your code!). The great thing about Pico-8 is that I can lookup any source code to the carts posted here and learn from that, but I find myself really struggling understand a lot of it, as I don't know Lua (or programming practices past the basics really). Right now I am working on expanding the pong clone from Pico-8 Zine#1 and it is going alright, but I am afraid that the lack of knowledge of Lua/Pico-8 functions will make me reach a standstill, or I will get frustrated and give up :(

Any advice you would give to a new programmer? Any books or articles you could recommend (especially about Lua, or basics of programming in general)? I have already gone through the zine and manual (however the manual doesn't explain things very well, but it is a good reference) multiple times and I use this BBS daily, so I am looking for any other resources.

So far I am having a blast and I think I can actually do this, but I would love some advice, so I won't give up. Any help would be greatly appreciated.

9
17 comments


I spent some time analyzing the palette and came up with some things that I find make it easier to use.
I decided to share it here in case others find it useful as well, so here goes.

First ting I did was map the colourspace. This makes it very easy to find nearby colours when shading or tinting.
The colourspace wraps horizontally thru the spectrum as illustrated by the double width block.

Next I reduced the colourspace to use single pixels instead of clusters. Less accurate but more compact.

Based on this I came up with an comfortable order of the 16 colours (as I found the default colour order not very user friendly). Apart from making it easier to find the right colour quickly, I wanted to make sure it looks pleasing :)
You can use this order regardless of your gfx software fo choice. I made sure the palette works whether it's presented in a single row, 2x8 or 4x4.

An added bonus is that the this order also wraps around nicely, as illustrated by the 'ring' versions on the right.

[ Continue Reading.. ]

73
13 comments


Hi Everyone,

My name is petri and I'm very enthusiastic about PICO-8 and PocketChip concept.

I decided to learn some coding and try to make my first little game. One of my favorite games from when I was a kid was Boulder Dash so demake for PICO-8 feels just right to do. It's just a mockup for now, but I will try to make it work.

@zep I would like to thank you for creating PICO-8. It's a lot of fun:)

1
1 comment


Cart #20786 | 2016-05-18 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

May 18 2016

I'm working on my first cart. I hope you'll excuse the crappy graphics!
Move your cross hairs with the arrow keys (0,1,2,3) and fire with Z (4).

The further down you catch a bomb, the more points you will get. And intercepting more than one bomb with the same shot will multiply the score you get.

You can't lose at the moment though :P

3
0 comments


Cart #20767 | 2016-05-18 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
5

There is a massive noise in your precious recording of 4'33" by John Cage in Carnegie Hall. Instead of four and a half minutes of silence -- electronic disaster in your headhones! Get rid of it by applying various filters to reach silence. Each slider controls one filter, which removes one element of noise when set to correct position.

  • Not all filters are needed every time.
  • Sometimes only one noise element is active.
  • Getting rid of one element makes others louder.

LEFT, RIGHT: Choose the filter
UP, DOWN: Move the filter slider

You need sound output to play this minigame.
Warning: Squeaky noises ensue! :-)

5
0 comments


I've done collision detection with object/object and object/tiles. But what is a good way to detect object/shape?

I have a 8x8 player sprite. You can move it, etc. Across the screen is the bad guy and he's shooting at you. If a his bullet hits the player, the player dies.

I want to use circfill() as the enemy bullet rather than a sprite.

I would have the player's _update() cycle check for the collision but what exactly would I check for?

My first thought was to loop through each of the player's hitbox x/y pairs and an use pget() to see if that location has changed to the color of the enemy bullet. But that sounds very expensive to do on every tick.

Is there a better way? I feel like there probably is.

Thoughts and feedback are appreciated.

2 comments


Cart #20709 | 2016-05-17 | Code ▽ | Embed ▽ | No License
22

Perhaps this is going to be useful for someone. This is a little keyboard handler I'm using in my code. It extends the functionality of the standard btn(k) function with detection of the onset of the key and its release. Sometimes it's useful to have those two and avoid btnp(k) repetition.

-- is_held(k) is true if the key k is held down
-- is_pressed(k) is true if the key has just been pressed by the user
-- is_released(k) is true if the key has just been released by the user

keys={}

function is_held(k) return band(keys[k], 1) == 1 end
function is_pressed(k) return band(keys[k], 2) == 2 end
function is_released(k) return band(keys[k], 4) == 4 end

function upd_key(k)
	if keys[k] == 0 then
		if btn(k) then keys[k] = 3 end
	elseif keys[k] == 1 then
		if btn(k) == false then keys[k] = 4 end
	elseif keys[k] == 3 then
		if btn(k) then keys[k] = 1
		else keys[k] = 4 end
	elseif keys[k] == 4 then
		if btn(k) then keys[k] = 3
		else keys[k] = 0 end
	end
end

function init_keys()
	for a = 0,5 do keys[a] = 0 end
end

function upd_keys()
	for a = 0,5 do upd_key(a) end
end

[ Continue Reading.. ]

22
10 comments


I've bounced around several threads to try and understand how to save game data but it's all kind of scattered, so I'm looking for something more concrete, or an example.

I've read section on memory in the manual and see the cstore() peek() and poke() stuff...but it's just it's just not clicking. I think it's because it's talked about in bytes and addresses, and that's foreign to me. But it seems like saving data between sessions is a do-able thing...I hope...?

I have two things I'm trying to do with save data...

  • Save a high score
  • Save a boolean to denote whether the player has unlocked a character

I understand that data won't persist between platforms, which is fine. I just want the data to be able to used between game sessions on the same device. So the first time I play the game and get a score, it's saved. I turn off the device/cart. Then I turn it back on and my high score is there.

Any guidance or code snippets are appreciated. This might be a good idea for a Fanzine article too (unless it's already covered and I skimmed over it).

Thanks

1
7 comments


I've seen varying techniques for update looping and am looking for insight/feedback on if one is any better than the other in terms of speed/efficiency.

Method #1 I see a lot is a global table of all the actors on the screen. So everything goes here and then the system _update() function is something like this.

actors={}

function _update()
   foreach(actors, function(obj)
      obj.update()
   end
end

This method makes sense. Every object then has its own update() method...but that feels kind of inefficient, especially if the update would be the same for like-actors.

Method #2 is grouping like-actors with each group have its own update() method, which is then called in the system update loop.

bullets={}
bullets.actors={}
bullets.update=function()
   foreach(bullets.actors, function(obj)
      ...do stuff to obj...
   end
end

badguys={}
badguys.actors={}
badguys.update=function()
   foreach(badguys.actors, function(obj)
      ...do stuff to obj...
   end
end

function _update()
   bullets.update()
   badguys.update()
end

[ Continue Reading.. ]

2
9 comments





This cart is basically a demonstration of a simple tool/function I've made to check/debug the music playing in one of my project, the function need no external dependency and should not clobber your variables as all of them are declared as local. You only need to call the function with the Y position as parameter (positive number are relative to the top of the screen, negative from the bottom) in your update screen function to display a bar with the current status of music playing.

There are four zone, one for each channel, the green/red bubble indicate is the channel is playing or not (green == playing, red, not playing) the number next to the bubble is the pattern used on that channel, and the bar on the bottom is the current position in the pattern.

The function itself:

function debug_music(y)
  if y < 0 then
    y = 128 - 17 + y
   end
   rectfill(0, y, 127, y+18, 0)
   rect(1, y+1, 125, y+16, 7)
   for c=0,3 do
 	   local p   = stat(16+c)
 	   local b   = stat(20+c)*25 / 32
 	   local col = 8
 	   if p > -1 then 
 	     col = 11 
 	   end
 	   circfill(9+c*32, 6+y, 2, col)
 	   print(p, 15+c*32, 4+y, 7)
	   rectfill(3+c*32, 10+y, 27+c*32, 13+y, 6)
	   if p >= 0 then
		   rectfill(3+c*32, 10+y, 3+b+c*32, 13+y, 3)
	   end
   end
end

[ Continue Reading.. ]

6
5 comments




Top    Load More Posts ->