Log In  

BBS > Community Superblog
All | Following | GIFs | Off-site

So I want to make a sound effect that only plays when a direction is pushed, and the trouble that I'm running into is that:

  • using (btn(input)) loops the sound so fast it almost crashes PICO-8
  • using (btnp(input)) only plays it when the button is first pressed

How do I make it so it plays consistently while pressing a direction, and loops at a normal speed? I tried making a timer that gets added to while a direction is pushed, but the only way I could find to do it was i+=1 which only added 1 a single time. Is a timer the right way to go or is there a more efficient way?

function move_player()
	newx=p.x
	newy=p.y

	if (btn(⬅️)) then 
		newx-=.1 p.sprite=d.left sfx(0)
			elseif (btn(➡️)) then 
				newx+=.1 p.sprite=d.right sfx(0)
					elseif (btn(⬆️)) then
						 newy-=.1 p.sprite=d.up sfx(0)
						elseif (btn(⬇️)) then
							 newy+=.1 p.sprite=d.down sfx(0)
	end

Here's a snippet of my code if it helps. Thanks!

4 comments


Apologies if this is a duplicate, I'm new to the forums and couldn't find anything similar when searching.

I was making some centred variants of graphics functions and found that omitting the colour parameter would result in the pen colour being set to black

I've broken it down so you can use the following snippet to observe the issue (pico-8 0.2.3)

function pen_col()
 return peek(0x5f25)&0xf
end

cls(1)
color() -- reset pen colour

print("default colour",0,0)
assert(pen_col()==6)

print("nil produces black",0,6,nil)
assert(pen_col()==0)

print("draw state is now black",0,12)
assert(pen_col()==0)

color() -- reset pen colour
_c=nil
print("colour parameter containing nil is black",0,18,_c)
assert(pen_col()==0)

color() -- reset pen colour
print("back to default colour",0,24)
assert(pen_col()==6)

In my usage this means that if I wrap for example print, I'll want to forward the colour value, but allow for it to be omitted, in order to work around the bug I have to read the current pen colour from the draw state to prevent draw state defaulting to black.

[ Continue Reading.. ]

3 comments


A customizable calendar.

Features:

  • Real-time changes: textcolor/backcolor of each item, language, first day of week, country
  • Languages: en, nl, fr, de, es, it
  • When holiday translation not available for specific language -> default english

  • Fixed holidays
  • Calulated holidays (e.g. easter/pentecost/....)
  • Payed/Normal holidays per country (only Belgium for the moment)
  • Holiday banner

  • Colors, language, first day of week and country are saved in cartdata
  • "Reset all" function

Cart #calendar-2 | 2021-10-20 | Code ▽ | Embed ▽ | No License
4

4
2 comments


Cart #zanepetuzo-0 | 2021-10-17 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
11

hi, so I was talking to my friend some time ago and we were discussing how to make randomly generated music better, and we ended up talking about generating the chord progression and the time signature first and then picking the notes randomly from there, he didn't believe this would work so here's my proof of concept, feel free to read the code and tell me some thoughts

and for the name of the cartridge, "c3510"(pronounced cesio) is a robot from a distopian worldbuilding i'm creating, he loves experimenting with music, so I thought it would be interesting to theme this cartridge as his "futuristic music box"

11
5 comments


Cart #kipopeyema-0 | 2021-10-17 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

1
1 comment


Early on in playing around with PICO-8 I wrote a function to print text with a black outline.

function prt_out(s,x,y,c)
print(s,x-1,y,0)
print(s,x+1,y)
print(s,x,y-1)
print(s,x,y+1)
print(s,x,y,c)
end

I imagine a lot of people have also done this and I can't be the only person who found it a bit clumsy and, near the end of a project when casting about for tokens, wondered if those five very similar print calls couldn't be reduced.

Nowadays we have P8SCII so I thought I'd have a look. Here are some candidates I've written with their token counts and times from my crude testing:

function p1(s,x,y,c) -- 42 tokens, 5.6 seconds
?'\f0\-f'..s..'\^g\-h'..s..'\^g\|f'..s..'\^g\|h'..s..'\^g\f'..chr(c+(c>9 and 87 or 48))..s,x,y
end

function p2(s,x,y,c) -- 26 tokens, 6.2667 seconds
for i in all(split'\f0\-f,\-h,\|f,\|h') do
?i..s,x,y
end
?s,x,y,c
end

function p3(s,x,y,c) -- 38 tokens, 5.6667 seconds
?'\f0\-f'..s..'\^g\-h'..s..'\^g\|f'..s..'\^g\|h'..s..'\^g\f'..sub(tostr(c,1),6,6)..s,x,y

[ [size=16][color=#ffaabb] [ Continue Reading.. ] [/color][/size] ](/bbs/?pid=98796#p)
21
6 comments


I wrote a blog post about making a generic method dispatch helper for 'foreach'.
It's more of a novelty than something really worth adding to code. It's better to just use 'for x in all(XS)' instead.

Here's the mini summary:

function callm(method, ...)
 local params={...}
 return function(o)
  if type(o)=="table" then
   local m=o[method]
   if type(m)=="function" then
    m(o,unpack(params))
   end
  end
 end
end

function _draw()
 cls()
 foreach(drawable, callm("draw", 11))
end

Check it out: https://kallanreed.com/2021/10/17/pico-8-generic-dispatch-with-parameters/

0 comments


Hey, I've recently taken a shot at bringing my digital-ink project perfect-freehand over to Pico8.

Cart #perfectfreehand0-0 | 2021-10-17 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

The idea is to render input points as polygons (or meshes, in this case) with variable widths. This one is not quite finished but I've found it so far an excellent challenge to improve the algorithm's performance and see how it would handle meshes rather than filled polygons. There's a lot more improvement to be done there—feel free to snoop around if you'd like!

3
0 comments


by IMLXH
Cart #bury-0 | 2021-10-17 | Code ▽ | Embed ▽ | No License
16


PICO-8 PCM COLAB: https://colab.research.google.com/drive/1HyiciemxfCDS9DxE98UCtNXas5TrM-5e?usp=sharing

So after reading carlc27843 and czarlo's explanations of how to digitize audio for Pico-8, I wanted to see if I could make things a little bit easier on myself by making a Colab to automate the process. Hope this is useful to someone!

16
9 comments


I was working on an earlier version of this tweetcart when I noticed a problem with ord used to poke in a single call (i.e. the three-parameter version).

The relevant portion:

s="ンH!\0イTvzw」😐゛\"%l_b<く゛■}ト0aOヤE⁘~わ、そ」う1U゛^Wヌ}ろ014ャ	⁸+Zc=:•ᶠ⬅️~ふO7dウ	➡️	イ⁙★wき&□0◜▶せ~p⁵\n:リ hU>ᶠみ○dI、U)7&⁸とv3r³\"ふ\"∧a]Z。F🐱■゛tᶜv¥⁷C],□y゜ウ+ふ$し+m&WIニ~_¥ホrへWW|Y7}Cd゛}ᵇ‖■へM_Eスvイ36ᵇめ-モeそ◀ラ	▥9gKE4ヒ(=ᶠ"
poke(17152,ord(s,1,#s))
--rest of the cart

On my Mac, at least, I got:

pico8(36303,0x10ab435c0) malloc: Incorrect checksum for freed object 0x7fca4d589600: probably modified after being freed.
Corrupt value: 0x3deadbeef
pico8(36303,0x10ab435c0) malloc: *** set a breakpoint in malloc_error_break to debug

[ Continue Reading.. ]

1 comment


So I currently have a movement system down for my player, and the sprite changes based on direction. Here's an excerpt:

function make_player()
	p={}
	p.x=3
	p.y=10
	p.sprite=4

end

function draw_player()
 spr(p.sprite,p.x*8,p.y*8)
end

function move_player()
	newx=p.x
	newy=p.y

	if (btn(⬅️)) newx-=.1 
	if (btn(➡️)) newx+=.1
	if (btn(⬆️)) newy-=.1
	if (btn(⬇️)) newy+=.1

	if (can_move(newx,newy)) then
	p.x=mid(0,newx,127)
	p.y=mid(0,newy,63)
	else
	p.x+=0
	p.y+=0
	end
end

function player_anim()
	if (btnp(⬅️)) p.sprite=3
	if (btnp(➡️)) p.sprite=2
	if (btnp(⬆️)) p.sprite=4
	if (btnp(⬇️)) p.sprite=1
end

function player_walk()

end

Now how would I go about adding footstep animations every second or so as a direction is pressed?

1
2 comments


Cart #fsm_boiler-0 | 2021-10-16 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA


--core
-- finite state machine (game state)
fsm={states={}}

-- make a state for the fsm system
function mk_state(state_name, f_enter, f_exec, f_exit)
s = {}
s.enter = f_enter
s.exec = f_exec
s.exit = f_exit
s.age=0
fsm.states[state_name] = s
return s
end

function set_state(new_state_name)

if(fsm.current ~= nil) then
-- exit old state
fsm.current.exit()
fsm.current.age=0
end

-- setup new state
fsm.current = fsm.states[new_state_name]
fsm.current.age=0
fsm.current.enter()
end

function _init()
-- set initial state to s1
fsm.current = s1
end

function _update60()
fsm.current.age+=1
fsm.current.exec()
end

-->8
--state 1

function s1_enter()
end

function s1_execute()

cls()
print("state_1: " .. s1.age, 10,10,9)
-- leave when s1 is older than 60 frames
if(s1.age>60) then
set_state("s2")
end
end

function s1_exit()
end

s1 = mk_state("s1", s1_enter, s1_execute, s1_exit)
-->8
--state 2

function s2_enter()
end

function s2_execute()

cls()
print("state_2: " .. s2.age, 40,10,8)
-- leave when s1 is older than 120 frames
if(s2.age>120) then
set_state("s1")
end
end

function s2_exit()
end
s2 = mk_state("s2", s2_enter, s2_execute, s2_exit)

1 comment


Cart #adventuregame-0 | 2021-10-16 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

This game is a remix of the adventure game tutorial

about my game that's conscious of Halloween.

Thank you for playing.

1
1 comment


Cart #turmoil-0 | 2021-10-16 | Code ▽ | Embed ▽ | No License
7

This is a demake of a game called Turmoil from various 8-bit computers.

The gameplay is a 2D Tempest, you quickly move around 7 grids and shoot incoming enemies.

Sometimes an enemy called 'Prize' appears at left or right bottom. if you release fire button (I did this because I hated unintentionally moving horizontally when playing Turmoil, and it gives a bit more depth to the gameplay as you shouldn't hold the button all the time.) and move the ship to it, you can earn big points. but if you don't grab it in time it will turn into a Supersonic Cannon Ball.

press left or right to select starting level from 1 to 9.

7
3 comments


The world is coming to an end.

Cart #pwp_release-0 | 2021-10-16 | Code ▽ | Embed ▽ | No License
37

You awaken in a hospital infested with zombies.
Someone has left a pumpgun for you to try and make your way out alive.

Controls

Left and right: Move
Up and down: Enter and exit doors.
Z: Throw grenade
X: Shoot / melee attack when grabbed by a zombie.

Manual

37
12 comments


Cart #colorpick-0 | 2021-10-15 | Code ▽ | Embed ▽ | No License
8

A little brain game. You have to select the name of the color.

Select as many color names as you can in 60 seconds.

Score:
+1 correct answer
-1 incorrect answer

8
6 comments


op
by dw817
Cart #op-0 | 2021-10-15 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
4

TO LOAD THIS cartridge in the Pico-8 system, from the immediate mode type:

LOAD #PO

Having seen the THUMBY device (see links below) I thought it surely must be possible to make a device just as small yet instead of using a very small up, down, left, right and (A) and (B) buttons, can't this all be done with a single button instead ?

So I set out to write a proof of concept example in Pico-8. In this it has only two buttons. A MODE on the side and a main center single button.

Button (O) is the center MAIN button and button (X) is the side MODE button.
For the IBM-pc this is key "Z" and "X."

To turn the system on, hold both for a moment. Hold both again to turn the system off.

[ Continue Reading.. ]

4
7 comments


Cart #db_reflection-1 | 2021-10-15 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
13


A simple demo of a reflection.

Press X to enable/disable the reflection effect.
Press Z to enable/disable the ripple effect.

Use up/down to move the view up and down i.e. change the amount of reflection on the screen.

Uses the extra palette to dim the portion of the screen where the reflection will be.
Draws everything else like normal above the reflection surface.
'memcopy's to the lines below the reflection surface, starting with the line immediately above it.
Adding an offset with some sin() calls moves each line a bit to allow the ripple effect. Downside is a little bit of mess at the edges.

[edit] Minor bug fix to make ripple effect constant with distance from the shore.

13
0 comments


Cart #tennispongmaster-2 | 2021-10-17 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

Tennis Pong Master

I'm trying to learn gamedev, it is my first game on Pico-8.

This is a simple pong game with a tennis theme for 1 or 2 players.

Player 1: left and right arrows.
Player 2: S / F

Update : 1 player mode added

1
1 comment


Pichrome-8

I've made a Chrome Extension for discovering Pico-8 carts

Hi everyone,
as part of my Cs50x Harvard Course, I had to make a Final Project and I decided to create something about Pico-8 (which I love).

I always felt like there were so many games and that it would be cool to have a random picker that would let me discover carts.
I think a Chrome Extension is perfect for that: let you disctract from working or from boring webcam meetings!
Your next Pico-8 game is just one clik away into your browser! :)

Link to the Chrome Webstore page: Chromepie-8

Features:

  • One click to the extension icon open a small card that automatically load a random carts from the first 500 featured one
  • You can play usign standard keyboard keys or with mouse input (when supported by the carts)
  • Click wherever out of the card to just stop the game and close the extension (Safe For Work!)
  • If you like the game, click the download button to have easy access to the .png cart

--> It's my first piece of "software" ever released, so any suggestion on comment is appreciated!

Thank to Lexaloffle for making Pico-8.

[ Continue Reading.. ]

3
0 comments




Top    Load More Posts ->