Log In  

@chermosi

Follow
Follow

So in Super Mario and similar games the character only jumps when you press the button, and if you just keep the same button press the character doesn't jump. You have to release the button and then press it again.

I've tried to implement a jump action and both with btn and btnp if I keep the button pressed the player keeps jumping forever (in btnp just slower).

How can I do this? Thank you! :)

P#63020 2019-03-25 15:02

I can't seem to find any tutorials on how to make monsters move or patrol or have movements routines.

Nothing fancy, something like:

Go from A to B, wait a few frames, go to C, wait again, go back to A and repeat.

The monster doesn't even have to notice the player, just walk its path.

I've tried with loops but I can't make it work.

Thank you very much!!! :D

P#62071 2019-02-19 13:42

I'm trying some math things to learn pico8 and programming in general.

After a few days and realizing that the square root in lua (and in every language?) only gives positive numbers, I’ve come to this monster to draw a simple circle haha

function _init()
end

function _update60()
cls(1)
end

function _draw()
--coordinates
line(64,0,64,128,2)
line(0,64,128,64,2)
manual_circle()
circ(64,64,63)
end

function manual_circle()
for x=0,50 do
radius=50
local y=-sqrt((radius^2)-(x^2))
pset(x+64,y+64,11)
end
for x=-50,0 do
radius=50
local y=-sqrt((radius^2)-(x^2))
pset(x+64,y+64,11)
end
for x=0,50 do
radius=50
local y=-sqrt((radius^2)-(x^2))
pset(x+64,-y+64,11)
end
for x=-50,0 do
radius=50
local y=-sqrt((radius^2)-(x^2))
pset(x+64,-y+64,11)
end
end

And it looks like this:

as you can see the function doesn't print the pixels continuosly as the circ function, probably because of the square root giving decimals.

What is the correct way of drawing a circle “manually”???

Thank you!

P#61759 2019-02-11 13:57 ( Edited 2019-02-11 13:58)

I'm learning to make hitbox collisions (instead of flags collisions).
Vertical collisions seem to work just fine but horizontals don't.
How can this be done?
Maybe hitbox collisions are just to complicated and shouldn't be used?
.
.
.

Cart [#hermo-0#] | Code | 2019-01-20 | License: CC4-BY-NC-SA | Embed

.
.
.

function _init()
    pad_x=45
    pad_y=45
    pad_width=30
    pad_height=30
    pad_color=7
    pad_speed=3

    ball_x=80
    ball_y=10
    ball_radius=4
    ball_color=8
    ball_speed_x=2
    ball_speed_y=2
end

function _update60()
    btnprss=false
    cls(1)

   --ball movement
    ball_x+=ball_speed_x
    ball_y+=ball_speed_y 

    --ball-screen collision
    if ball_x<0 or ball_x>128 then
        ball_speed_x=-ball_speed_x
    end

    if ball_y<0 or ball_y>128 then
        ball_speed_y=-ball_speed_y
    end
    --pad movement
    if btn(0) then
        btnprss=true
        pad_speed=-5
    end

    if btn(1) then
        btnprss=true
        pad_speed=5
    end

    pad_x+=pad_speed

    if btnprss==false then
        pad_speed=pad_speed/2
    end

    if pad_x<1 or pad_x>126-pad_width then
        pad_x=mid(1,pad_x,126-pad_width)
    end

    pad_color=7
    if ball_box(pad_x,pad_y,pad_width,pad_height) then
        pad_color=8
        ball_speed_y=-ball_speed_y
    end
end

function _draw()
    rectfill(pad_x,pad_y,pad_x+pad_width,pad_y+pad_height,pad_color)
    circfill(ball_x,ball_y,ball_radius,ball_color)
end

function ball_box(box_x,box_y,box_w,box_h)
    --conditions where there are no collisions
    if ball_y-ball_radius>box_y+box_h then
        return false
    end
    if ball_y+ball_radius<box_y then
        return false
    end
    if ball_x-ball_radius>box_x+box_w then
        return false
    end
    if ball_x+ball_radius<box_x then
        return false
    end
    return true
end
P#61033 2019-01-20 17:33

Hello!

I'm learning Pico8 and programming in general, so I'm trying some very very simple things.

I've made a triangle using lines, and using the arrow keys I can move one of the vertices of the triangle.
How can I make it so if I push button5 the arrow keys stop moving that vertex and start moving the second one, press again and changes to the third one and finally press again and changes to the first.

Thank you so much!

So far this is the code I have:

function _init()
    x1=100
    y1=20
    x2=40
    y2=40
    x3=60
    y3=60
    c=7
end

function _update60()
    cls(1)

    if btn(0) then
        x1-=1
    end
    if btn(1) then
        x1+=1
    end
    if btn(2) then
        y1-=1
    end
    if btn(3) then
        y1+=1
    end
end

function _draw()
    line(x1,y1,x2,y2,c)
    line(x2,y2,x3,y3,c)
    line(x3,y3,x1,y1,c)
end
P#59489 2018-11-30 07:20 ( Edited 2018-11-30 07:21)

I've read somewhere that you can show a flipped sprite using TRUE like in spr(1,x,y,TRUE) but it doesn't seem to work for me.

Is it possible? what i'm i doing wrong?

thank you!!! :)

P#56928 2018-09-20 10:09 ( Edited 2018-09-20 14:33)

Hello!!!

I'm starting with PICO-8 and loving it!

I’m new to programming and the only thing that I don't like that much is the code editor. The font its pretty hard to read and the horizontal scrolling with so few characters makes it difficult to find errors.

I've read that you can just open the .p8 file and edit them with a text editor and looks like it works just fine but at the end of the file there are some weird big block of characters. Is this expected? If I edit a file with a text editor (lets say Notepad++) I just edit my code and ignore the block of weird characters???

Thank you!!! :D

P#56100 2018-09-03 03:43 ( Edited 2018-09-03 10:41)

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-08-23 09:47 | 0.069s | 4194k | Q:36