From ac5e9702483b5806c08dfeff0662ff57cc64ea41 Mon Sep 17 00:00:00 2001 From: Matt Phelps Date: Thu, 23 Jan 2020 13:19:29 -0500 Subject: [PATCH 1/9] added orig config --- config.txt | 206 ++++++++++++++++++++++++++--------------------------- 1 file changed, 103 insertions(+), 103 deletions(-) diff --git a/config.txt b/config.txt index 0634ba7..a196659 100755 --- a/config.txt +++ b/config.txt @@ -1,103 +1,103 @@ -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// Configuration for pico-8 -// -// config.txt is read on startup and saved on exit. -// To generate the default config.txt, delete this file. -// -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// :: Video Settings - -window_size 0 0 // window width, height -screen_size 0 0 // screen width, height (stretched to window) -show_fps 0 // Draw frames per second in the corner - - -// :: Window Settings - -windowed 0 // 1 to start up in windowed mode -window_position -1 -1 // x and y position of window (-1, -1 to let the window manager decide) -frameless 0 // 1 to use a window with no frame -fullscreen_method 1 // 0 maximized window (linux) 1 borderless desktop-sized window 2 fullscreen - - -// :: System Settings - -foreground_sleep_ms 2 // number of milliseconds to sleep each frame. Try 10 to conserve battery power - -background_sleep_ms 10 // number of milliseconds to sleep each frame when running in the background - -sessions 14 // number of times program has been run - -// (scancode) hold this key down and left-click to simulate right-click -rmb_key 0 // 0 for none 226 for LALT - -// Desktop for saving screenshots etc. Defaults to $HOME/Desktop -desktop_path - - - -// :: Audio Settings (use "volume" for PICO-8) - -sound_volume 256 // 0..256 -music_volume 256 // 0..256 - - -// :: usually 1024. Try 2048 if you get choppy sound - -mix_buffer_size 1024 - - -// :: - -version 0.1.12c - -// audio volume: 0..256 -volume 256 - - -// Location of pico-8's root folder -root_path C:/Users/Matth/AppData/Roaming/pico-8/carts/ - - -// Location of cartridge save data -cdata_path C:/Users/Matth/AppData/Roaming/pico-8/cdata/ - - -// Specify which player index joystick control begins at (0..7) -joystick_index 0 - - -// Custom keyboard scancodes for buttons. player0 0..6, player1 0..5 -button_keys 0 0 0 0 0 0 0 0 0 0 0 0 0 - -// Play notes as they are plotted in frequency mode -live_notes 0 - -// iff 1: when using keyboard cursor, snap to closest pixel / map cel -cursor_snap 0 - -// maximum length of gif in seconds (1..120, default 8) -gif_len 8 - -// 0 default 1 dark blue background in code editor 2 black background in code editor 3 gray background in code editor -gui_theme 0 - -// scale of screenshots and gifs // 2 means 256x256 -screenshot_scale 3 -gif_scale 2 - -// when 1 can enter glyphs using shift-A..Z -shift_glyphs 1 - -// 0 for off. 1 to allow control of a cart's framerate due to host machine's cpu capacity (recommended) -host_framerate_control 1 - -// filter splore cartridges -// 0 off 1 on (exclude cartridge tagged as 'mature' by community) -splore_filter 0 - -// tab display width (1 ~ 4 spaces) -tab_width 1 - +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// Configuration for pico-8 +// +// config.txt is read on startup and saved on exit. +// To generate the default config.txt, delete this file. +// +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +// :: Video Settings + +window_size 0 0 // window width, height +screen_size 0 0 // screen width, height (stretched to window) +show_fps 0 // Draw frames per second in the corner + + +// :: Window Settings + +windowed 0 // 1 to start up in windowed mode +window_position -1 -1 // x and y position of window (-1, -1 to let the window manager decide) +frameless 0 // 1 to use a window with no frame +fullscreen_method 1 // 0 maximized window (linux) 1 borderless desktop-sized window 2 fullscreen + + +// :: System Settings + +foreground_sleep_ms 2 // number of milliseconds to sleep each frame. Try 10 to conserve battery power + +background_sleep_ms 10 // number of milliseconds to sleep each frame when running in the background + +sessions 16 // number of times program has been run + +// (scancode) hold this key down and left-click to simulate right-click +rmb_key 0 // 0 for none 226 for LALT + +// Desktop for saving screenshots etc. Defaults to $HOME/Desktop +desktop_path + + + +// :: Audio Settings (use "volume" for PICO-8) + +sound_volume 256 // 0..256 +music_volume 256 // 0..256 + + +// :: usually 1024. Try 2048 if you get choppy sound + +mix_buffer_size 1024 + + +// :: + +version 0.1.12c + +// audio volume: 0..256 +volume 256 + + +// Location of pico-8's root folder +root_path /Users/m231174/Library/Application Support/pico-8/carts/ + + +// Location of cartridge save data +cdata_path /Users/m231174/Library/Application Support/pico-8/cdata/ + + +// Specify which player index joystick control begins at (0..7) +joystick_index 0 + + +// Custom keyboard scancodes for buttons. player0 0..6, player1 0..5 +button_keys 0 0 0 0 0 0 0 0 0 0 0 0 0 + +// Play notes as they are plotted in frequency mode +live_notes 0 + +// iff 1: when using keyboard cursor, snap to closest pixel / map cel +cursor_snap 0 + +// maximum length of gif in seconds (1..120, default 8) +gif_len 8 + +// 0 default 1 dark blue background in code editor 2 black background in code editor 3 gray background in code editor +gui_theme 0 + +// scale of screenshots and gifs // 2 means 256x256 +screenshot_scale 3 +gif_scale 2 + +// when 1 can enter glyphs using shift-A..Z +shift_glyphs 1 + +// 0 for off. 1 to allow control of a cart's framerate due to host machine's cpu capacity (recommended) +host_framerate_control 1 + +// filter splore cartridges +// 0 off 1 on (exclude cartridge tagged as 'mature' by community) +splore_filter 0 + +// tab display width (1 ~ 4 spaces) +tab_width 1 + From 7bbc879d7255eb8ab3da2888bc00ddb9f1a8ef2d Mon Sep 17 00:00:00 2001 From: Matt Phelps Date: Thu, 23 Jan 2020 13:23:32 -0500 Subject: [PATCH 2/9] windowed mode default --- config.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.txt b/config.txt index a196659..02f50c7 100755 --- a/config.txt +++ b/config.txt @@ -16,7 +16,7 @@ show_fps 0 // Draw frames per second in the corner // :: Window Settings -windowed 0 // 1 to start up in windowed mode +windowed 1 // 1 to start up in windowed mode window_position -1 -1 // x and y position of window (-1, -1 to let the window manager decide) frameless 0 // 1 to use a window with no frame fullscreen_method 1 // 0 maximized window (linux) 1 borderless desktop-sized window 2 fullscreen From 6649574a35bb10b688f93dd43e0a80c9d2deb6c0 Mon Sep 17 00:00:00 2001 From: Matt Phelps Date: Thu, 23 Jan 2020 13:46:32 -0500 Subject: [PATCH 3/9] basic structure --- carts/game2.p8 | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 carts/game2.p8 diff --git a/carts/game2.p8 b/carts/game2.p8 new file mode 100644 index 0000000..b9c424f --- /dev/null +++ b/carts/game2.p8 @@ -0,0 +1,55 @@ +pico-8 cartridge // http://www.pico-8.com +version 18 +__lua__ +-- game 2 +-- by matt phelps + +function _init() + +end + +function _update() + +end + +function _draw() + -- space + cls(c['blue']) + -- ship + draw_ship() +end + + +-->8 +-- config (pg 2) +c = { + black = 0, blue = 1, maroon = 2, + green = 3, brown = 4, dark_gray = 5, + light_gray = 6, white = 7, + red = 8, orange = 9, yellow = 10, + lime = 11, light_blue = 12, + lavender = 13, pink = 14, tan = 15 +} + +sh = { + x = 40, + y = 40 +} + +-->8 +-- updating (pg 3) +function move_ship() + +end +-->8 +-- drawing (pg 4) +function draw_ship() + rect(sh.x-3,sh.y-3,sh.x+3,sh.y+3,c['orange']) +end +__gfx__ +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 From f53b3696fb4c392b9514a8881d119c657d5618f2 Mon Sep 17 00:00:00 2001 From: Matt Phelps Date: Fri, 24 Jan 2020 01:51:40 -0500 Subject: [PATCH 4/9] particle functions --- carts/game2.p8 | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/carts/game2.p8 b/carts/game2.p8 index b9c424f..31690e7 100644 --- a/carts/game2.p8 +++ b/carts/game2.p8 @@ -3,7 +3,7 @@ version 18 __lua__ -- game 2 -- by matt phelps - +-- == main methods == function _init() end @@ -14,14 +14,20 @@ end function _draw() -- space - cls(c['blue']) + draw_space() -- ship draw_ship() + + -- test + circfill(20,20,1,10) + circ(30,20,1,10) + circfill(20,30,2,10) + circ(30,30,2,10) end -->8 --- config (pg 2) +-- == global config == c = { black = 0, blue = 1, maroon = 2, green = 3, brown = 4, dark_gray = 5, @@ -31,21 +37,47 @@ c = { lavender = 13, pink = 14, tan = 15 } +-->8 +-- == space == +function draw_space() + cls(c['blue']) +end +-->8 +-- == the ship == +---- conf sh = { x = 40, y = 40 } - --->8 --- updating (pg 3) +---- updates function move_ship() end --->8 --- drawing (pg 4) +---- draws function draw_ship() rect(sh.x-3,sh.y-3,sh.x+3,sh.y+3,c['orange']) end + +-->8 +-- == particles == +---- conf +part = {} + +---- updates +---- draws + +-->8 +-- == ext helper func == +function add_new_dust(_x,_y,_dx,_dy,_l,_s,_g,_p,_f) + add(dust, { + fade=_f,x=_x,y=_y,dx=_dx,dy=_dy,life=_l,orig_life=_l,rad=_s,col=0,grav=_g,p=_p,draw=function(self) + pal()palt()circfill(self.x,self.y,self.rad,self.col) + end,update=function(self) + self.x+=self.dx self.y+=self.dy + self.dy+=self.grav self.rad*=self.p self.life-=1 + if type(self.fade)=="table"then self.col=self.fade[flr(#self.fade*(self.life/self.orig_life))+1]else self.col=self.fade end + if self.life<0then del(dust,self)end end}) + end __gfx__ 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 From 39470d892192529d879c10633a2a81a8c9a50a3e Mon Sep 17 00:00:00 2001 From: Matt Phelps Date: Fri, 24 Jan 2020 13:20:52 -0500 Subject: [PATCH 5/9] flame particles floating up --- carts/game2.p8 | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/carts/game2.p8 b/carts/game2.p8 index 31690e7..b34ce3e 100644 --- a/carts/game2.p8 +++ b/carts/game2.p8 @@ -9,7 +9,8 @@ function _init() end function _update() - + move_ship() + update_particles() end function _draw() @@ -17,6 +18,8 @@ function _draw() draw_space() -- ship draw_ship() + -- particles + draw_particles() -- test circfill(20,20,1,10) @@ -52,6 +55,20 @@ sh = { ---- updates function move_ship() + if btn(0) then sh.x-=2 end + if btn(1) then sh.x+=2 end + if btn(2) then sh.y-=2 end + if btn(3) then sh.y+=2 end + if btn(4) then + --an example passing a table for the color (flames?) + for i=1,10 do + add_new_dust(sh.x,sh.y, + rnd(1)-0.5,rnd(1)-2, -- dx, dy + rnd(20)+10,rnd(1)+1, -- life, rad + 0, 0.8, -- grav, perc + flame_sequence) + end + end end ---- draws function draw_ship() @@ -61,13 +78,29 @@ end -->8 -- == particles == ---- conf -part = {} - +dust = {} +flame_sequence = {7,7,7,7,7,7,6,6,6,6,6,5,5,9,9,10,10,10,10,10} ---- updates +function update_particles() + for d in all(dust) do d:update() end +end ---- draws +function draw_particles() + for d in all(dust) do d:draw() end +end -->8 -- == ext helper func == +-- CREDIT: DocRobs (https://www.lexaloffle.com/bbs/?pid=58211) +-- _x coordinate of dust +-- _y coordinate of dust +-- _dx x velocity +-- _dy y velocity +-- _l lifespan +-- _s starting radius +-- _g gravity +-- _p percentage shrink +-- _f col or table for fade function add_new_dust(_x,_y,_dx,_dy,_l,_s,_g,_p,_f) add(dust, { fade=_f,x=_x,y=_y,dx=_dx,dy=_dy,life=_l,orig_life=_l,rad=_s,col=0,grav=_g,p=_p,draw=function(self) From 1f5c02bb29770f9929ad9444e129309cb8de7320 Mon Sep 17 00:00:00 2001 From: Matt Phelps Date: Tue, 28 Jan 2020 00:07:57 -0500 Subject: [PATCH 6/9] directional flame particles. Next step: asteroids game style --- carts/game2.p8 | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/carts/game2.p8 b/carts/game2.p8 index b34ce3e..31db4e4 100644 --- a/carts/game2.p8 +++ b/carts/game2.p8 @@ -26,6 +26,7 @@ function _draw() circ(30,20,1,10) circfill(20,30,2,10) circ(30,30,2,10) + print(debug_str) end @@ -54,16 +55,19 @@ sh = { } ---- updates function move_ship() - - if btn(0) then sh.x-=2 end - if btn(1) then sh.x+=2 end - if btn(2) then sh.y-=2 end - if btn(3) then sh.y+=2 end - if btn(4) then + local dx, dy + dx = {0,0} + dy = {0,0} + if btn(0) then sh.x+=2 dx = {dx[1]-1,dx[2]-3} dy = {dy[1]+1,dy[2]-1} end + if btn(1) then sh.x-=2 dx = {dx[1]+3,dx[2]+1} dy = {dy[1]+1,dy[2]-1} end + if btn(2) then sh.y+=2 dx = {dx[1]+1,dx[2]-1} dy = {dy[1]-1,dy[1]-3} end + if btn(3) then sh.y-=2 dx = {dx[1]+1,dx[2]-1} dy = {dy[1]+3,dy[2]+1} end + if btn(0) or btn(1) or btn(2) or btn(3) then + debug_str = dx[1] .. ' '.. dx[2] .. ',' .. dy[1] .. ' '..dy[2] --an example passing a table for the color (flames?) for i=1,10 do add_new_dust(sh.x,sh.y, - rnd(1)-0.5,rnd(1)-2, -- dx, dy + dx[1]-rnd(abs(dx[1]-dx[2])),dy[1]-rnd(abs(dy[1]-dy[2])), -- dx, dy rnd(20)+10,rnd(1)+1, -- life, rad 0, 0.8, -- grav, perc flame_sequence) @@ -91,6 +95,9 @@ end -->8 -- == ext helper func == +local debug_str = '' +-- sign +function sign(x) return x>0 and 1 or x<0 and -1 or 0 end -- CREDIT: DocRobs (https://www.lexaloffle.com/bbs/?pid=58211) -- _x coordinate of dust -- _y coordinate of dust From a6525efb9def13dbdfc47cdc23d716a0a9a966a3 Mon Sep 17 00:00:00 2001 From: Matt Phelps Date: Wed, 29 Jan 2020 09:32:04 -0500 Subject: [PATCH 7/9] Added separate game file for planet experimentation --- carts/planet.p8 | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 carts/planet.p8 diff --git a/carts/planet.p8 b/carts/planet.p8 new file mode 100644 index 0000000..2690c97 --- /dev/null +++ b/carts/planet.p8 @@ -0,0 +1,39 @@ +pico-8 cartridge // http://www.pico-8.com +version 18 +__lua__ +-- planet tests +-- by matt phelps +-- == main methods == +function _init() + +end + +function _update() + +end + +function _draw() + +end + + +-->8 +-- == global config == +c = { + black = 0, blue = 1, maroon = 2, + green = 3, brown = 4, dark_gray = 5, + light_gray = 6, white = 7, + red = 8, orange = 9, yellow = 10, + lime = 11, light_blue = 12, + lavender = 13, pink = 14, tan = 15 +} + + + +__gfx__ +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 From a885eb67de5d6b00f6642a08ffbda734f43a633b Mon Sep 17 00:00:00 2001 From: Matt Phelps Date: Wed, 29 Jan 2020 09:32:53 -0500 Subject: [PATCH 8/9] added separate game file for rocket experimentation --- carts/rocket.p8 | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 carts/rocket.p8 diff --git a/carts/rocket.p8 b/carts/rocket.p8 new file mode 100644 index 0000000..2690c97 --- /dev/null +++ b/carts/rocket.p8 @@ -0,0 +1,39 @@ +pico-8 cartridge // http://www.pico-8.com +version 18 +__lua__ +-- planet tests +-- by matt phelps +-- == main methods == +function _init() + +end + +function _update() + +end + +function _draw() + +end + + +-->8 +-- == global config == +c = { + black = 0, blue = 1, maroon = 2, + green = 3, brown = 4, dark_gray = 5, + light_gray = 6, white = 7, + red = 8, orange = 9, yellow = 10, + lime = 11, light_blue = 12, + lavender = 13, pink = 14, tan = 15 +} + + + +__gfx__ +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 From 6c53ecf4b06ea3538bfd197a4f68154216657116 Mon Sep 17 00:00:00 2001 From: Matt Phelps Date: Wed, 29 Jan 2020 15:10:39 -0500 Subject: [PATCH 9/9] Rotatable asteroid rocket DEMO --- carts/rocket.p8 | 51 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/carts/rocket.p8 b/carts/rocket.p8 index 2690c97..fd56e42 100644 --- a/carts/rocket.p8 +++ b/carts/rocket.p8 @@ -9,11 +9,21 @@ function _init() end function _update() - + if (btn(0)) then center.angle += 0.02 end + if (btn(1)) then center.angle -= 0.02 end + if (btn(3)) then -- speed up + center.speed = min(20,center.speed+center.acc) + else -- slow down + center.speed = max(0,center.speed-center.decel) + end + center.x = (center.x + center.speed*cos(center.angle))%128 + center.y = (center.y + center.speed*sin(center.angle))%128 end function _draw() - + cls(3) + draw_rocket() + print('speed: '..center.speed,1,1,c['lime']) end @@ -27,9 +37,42 @@ c = { lime = 11, light_blue = 12, lavender = 13, pink = 14, tan = 15 } +function x(r) + if r == nil or r.r == nil or r.a == nil then return nil end + return r.r*cos(center.angle+r.a) +end +function y(r) + if r == nil or r.r == nil or r.a == nil then return nil end + return r.r*sin(center.angle+r.a) +end - - +center = {x=50,y=50,angle=0,speed=0,acc=2,decel=.5} +rock = { + { r = 9, a = 0 }, + { r = 8, a = 0.35 }, + { r = 0, a = 0.5 }, + { r = 8, a = 0.65 }, + { r = 9, a = 0 }, +} +-->8 +-- == rocket == +function draw_rocket() + -- center + pset(center.x,center.y,c['black']) + color(c['black']) + local r1 = rock[1] + line(center.x+x(r1),center.y+y(r1), + center.x+x(r1),center.y+y(r1)) + for r in all(rock) do + line(center.x+x(r), + center.y+y(r)) + end +end +-->8 +-- == helper func == +function btw(a,b,c) + return a >= b and a <= c +end __gfx__ 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000