Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

PICO-8: Top-Down Adventure Game Tutorial

A beginner-level tutorial for making a top-down adventure game in PICO-8. · By MBoffin (Dylan Bennett)

Ep.4 When ever I enter a new area the collisions are all janky and not set in the write spots.

A topic by SabeDoesThings created Sep 06, 2022 Views: 174 Replies: 2
Viewing posts 1 to 3

--game loop

function _init()

map_setup()

make_player()

end

function _update()

move_player()

end

function _draw()

cls()

draw_map()

draw_player()

end

-->8

--map code

function map_setup()

--map tile settings

wall = 0

tools = 1

water = 1

anim1 = 3

anim2 = 4

lose = 6

win = 7

end

function draw_map()

map_x = flr(p.x / 16) * 16

map_y = flr(p.y / 16) * 16

camera(map_x * 8, map_y * 8)

map(0, 0, 0, 0, 128, 64)

end

function is_tile(tile_type, x, y)

tile = mget(x, y)

has_flag = fget(tile, tile_type)

return has_flag

end

function can_move(x, y)

return not is_tile(wall, x, y)

end

-->8

--player code

function make_player()

p = {}

p.x = 8

p.y = 7

p.sprite = 1

p.tools = 0

end

function draw_player()

spr(p.sprite, p.x * 8, p.y * 8)

end

function move_player()

new_x = p.x

new_y = p.y

if (btn(⬅️)) new_x -= 0.1

if (btn(➡️)) new_x += 0.1

if (btn(⬆️)) new_y -= 0.1

if (btn(⬇️)) new_y += 0.1

if (can_move(new_x, new_y)) then

p.x = mid(0, new_x, 127)

p.y = mid(0, new_y , 63)

else

sfx(0)

end

Developer (1 edit)

I see two things that may be tripping you up. In your map_setup() function, you have both tools and water set to 1, but I think you probably meant to have one of those be 2 instead.

In your move_player() function, you have it adding 0.1 on button presses, rather than 1. That will definitely make player movement a bit odd.

I hope that helps! If not, let me know and I'll be happy to help debug further.

thank you