Log In  
Log In  

I've started doing something in Pico-8, but when i am trying to follow the particle tutorial from Picozine 1 (even if i get the text correct) and run it i get an error like

This is the code: http://hastebin.com/akaqebefav.lua

Any help?

P#18037 2015-12-25 08:30 ( Edited 2016-01-01 22:46)

:: impbox

on line 40 you have

 s.dx = (rnd(.8).4)

maybe it should be

 s.dx = (rnd(.8) - .4)

i'm not sure what the intention of that line is so i'm just guessing

P#18038 2015-12-25 09:01 ( Edited 2015-12-25 14:01)

That worked but i got another error:

P#18039 2015-12-25 09:35 ( Edited 2015-12-25 14:35)

Can you paste the code somewhere?

P#18041 2015-12-25 11:18 ( Edited 2015-12-25 16:18)

Here it is.

pico-8 cartridge // http://www.pico-8.com
version 5
__lua__
--super wheelbot!!
--by dynamicill

function _init()
 level=2
 px=10
 py=104
 pstate=0
 pspr=0
 pdir=0
 pat=0
 pdied=false

 smoke={}
 cursorx=50
 cursory=50
 color=7

 if level==1 then
  px=10
  py=104
 end
end

function canfall()
 --get the map tile under the player
 v=mget(flr((px+4)/8),flr((py+8)/8))
 --see if it's flagged as wall
 return not fget(v,0)
end

function change_state(s)
 pstate=s
 pat=0
end

function make_smoke(x,y,init_size,col)
 local s = {}
 s.x=x
 s.y=y
 s.col=col
 s.width = init_size
 s.width_final = init_size + rnd(3)+1
 s.t=0
 s.max_t = 30+rnd(10)
 s.dx = (rnd(.8) - .4)
 s.dy = rnd(.05)
 s.ddy = .02
 add(smoke,s)
 return s
end

function move_smoke(sp)
 if (sp.t > sp.max_t) then
  del(smoke,sp)
 end
 if (sp.t > sp.max_t15) then
 sp.width +=1
 sp.width = min(sp.width,sp.width_final)
 end
 sp.x = sp.x + sp.dx
 sp.y = sp.y + sp.dy
 sp.dy= sp.dy+ sp.ddy
 sp.t = sp.t + 1
end

function draw_smoke(s)
 circfill(s.x,s.y,s.width,s.col)
end

function _update()
 if pdied==false then
  b0=btn(0) --button0 state
  b1=btn(1) --button1 state
  b2=btn(2) --button2 state

  px=(px+128)%128 --no bounds left and right
  pat+=1

  --idle state
  if pstate==0 then
   pspr=0
   if (b0 or b1) change_state(1)
   if (b2) change_state(3)
   if (canfall()) change_state(2)
  end

  --walk state
  if pstate==1 then
   if (b0) pdir=-1 sfx(0)
   if (b1) pdir=1 sfx(0)
   px+=pdir*min(pat,2)
   pspr=flr(pat/2)%2

   if (not(b0 or b1)) sfx(1) change_state(0)
   if (b2) change_state(3)
   if (canfall()) change_state(2)
  end

  --fall state
  if pstate==2 then
   pspr=32
   sfx(2) 
   if (canfall()) then
    if (b0)px-=1 --steer left
    if (b1)px+=1 --steer right
    py+=min(4,pat) --move the player
    if (not canfall()) py=flr(py/8)*8 --check ground contact
   else
    py=flr(py/8)*8 --fix position when we hit ground
    change_state(0)
   end
  end
 end

 --jump state
 if pstate==3 then
  pspr=1
  py-=6-pat
  if (b0) px-=2
  if (b1) px+=2
  if (not b2 or pat>7) change_state(0)
 end

 --player death
 if py>=134 then
  if pdied==false then
   sfx(3)
   pdied=true
  end
 end

 foreach(smoke, move_smoke)
 if btn(0,0) then cursorx=1 end
 if btn(1,0) then cursorx+=1 end
 if btn(2,0) then cursory-=1 end
 if btn(3,0) then cursory+=1 end
 if btn(4,0) then color = flr(rand(16)) end
 make_smoke(cursorx,cursory,rnd(4),color)
 end
end

function _draw()
 --draw the world
 map(0,0,0,0,16,16)
 --draw the player
 spr(pspr,px,py,1,1,pdir==-1)
 --draw smoke
 foreach(smoke,draw_smoke)
end
P#18042 2015-12-25 11:40 ( Edited 2015-12-25 16:40)
:: hoytie

Looks like you have an extra "end" at the end of this block:

foreach(smoke, move_smoke)
if btn(0,0) then cursorx=1 end
if btn(1,0) then cursorx+=1 end
if btn(2,0) then cursory-=1 end
if btn(3,0) then cursory+=1 end
if btn(4,0) then color = flr(rand(16)) end
make_smoke(cursorx,cursory,rnd(4),color)
end
end

P#18043 2015-12-25 12:01 ( Edited 2015-12-25 17:01)

Aw shot! didn't notice that, but then next i have another problem:

What i could tell is that the tutorial was made before some bugs were fixed in this version. :|

P#18044 2015-12-25 12:03 ( Edited 2015-12-25 17:03)
:: matt
if (sp.t > sp.max_t15) then

should be something like

if (sp.t > sp.max_t - 15) then

here's code that runs: https://transfer.sh/ZksND/smoke.p8

though it doesn't look like it should, so there'll be a few more things to fix in there

P#18046 2015-12-25 14:49 ( Edited 2015-12-25 19:51)

thanks, this worked out, the picozine had grammatical errors sometimes, :P

Also, do anyone know how to make the player bump from the ceiling of the block and aswell how to do single-screen levels?

P#18047 2015-12-25 15:01 ( Edited 2015-12-25 20:57)

Yes, but it won't be of any use to you. Do you understand what the program from picozine does and how it works? There is no point in just typing in the source code. I recommend starting with something very very simple, like a pixel moved by arrow keys. Can you do that?

P#18055 2015-12-26 11:11 ( Edited 2015-12-26 16:11)

Yeah. Seems simple. i'm doing a platformer based off the tutorial from Picozine 2

P#18056 2015-12-26 11:14 ( Edited 2015-12-26 16:14)
:: Meir

Hey Dynamicill, if it helps here's a template I put together for making platformer games. I tried to comment it helpfully; it's an adaptation of this one: https://www.lexaloffle.com/bbs/?tid=2119. I copied it out manually to really get familiar with it.

P#18105 2015-12-31 07:07 ( Edited 2015-12-31 12:07)
:: Meir

Oop, here it is, I think this time.

Cart [#18106#] | Code | 2015-12-31 | License: CC4-BY-NC-SA | Embed

Once having copied it out, I made the necessary changes where I saw fit. I aimed for it to be reasonably customisable, but it was intended for personal use so may be a bit of a hassle to reuse, best of luck regardless!

P#18107 2015-12-31 07:16 ( Edited 2015-12-31 12:16)

Looks good.

P#18118 2016-01-01 17:46 ( Edited 2016-01-01 22:46)

[Please log in to post a comment]

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-05-23 15:05 | 0.046s | 4194k | Q:46