Log In  
Log In  

I been having trouble figuring out how to draw a map (room)
:(
Can someone do a cartridge that does nothing else but draw a map.
So I don't get lost in code for player controls, etc...
Thank you so much in advance :)

P#11096 2015-06-03 16:03 ( Edited 2017-02-02 17:50)

same here
and I'm a big fan of voxatron i use it alot

P#11097 2015-06-03 16:08 ( Edited 2015-06-03 20:08)

If you've arranged sprites on the map, then you use mapdraw() to draw a section of the map.

For example, if you used the map editor to place sprites on the map starting in the top left (0, 0) and spanning 3 tiles wide and 5 tiles high, you can draw that section to the screen at (41, 37) for example, by doing this:

mapdraw(0, 0, 41, 37, 3, 5)

Does that help at all?

EDIT: here is a cartridge of that example

Cart [#11109#] | 2015-06-03 | License: CC4-BY-NC-SA | Embed

P#11108 2015-06-03 18:40 ( Edited 2015-06-03 22:50)

Cart [#11131#] | 2015-06-05 | No License | Embed

Thank you so much, it did help a lot :)

How can I make my character collide with sprites?

plr={}
plr.x=5
plr.y=5
plr.spr=16
plr.spd=1
plr.mv=false

function move()
    plr.mv=true
    plr.spr+=1
    if plr.spr>25 then
        plr.spr=17
        end
end

function _update()
        plr.mv=false

        if btn(0) then 
                plr.x-=plr.spd
                move()
        end
        if btn(1) then 
                plr.x+=plr.spd
                move()
        end     
        if btn(2) then 
                plr.y-=plr.spd
                move()
        end
        if btn(3) then 
                plr.y+=plr.spd  
                move()  
        end

     if not plr.mv then
            plr.spr=16
            end

end

function _draw()
  cls()
  mapdraw(0, 0, 0, 30, 16, 9)
  spr(plr.spr,plr.x,plr.y)
end
P#11119 2015-06-04 00:37 ( Edited 2015-06-05 05:43)

How can I make my character collide with sprites?

P#11132 2015-06-05 01:44 ( Edited 2015-06-05 05:44)
:: tenpn

Check out the jelpi demo - full source, and platformer-style collisions. I'm sure you can adapt it?

P#11145 2015-06-06 09:23 ( Edited 2015-06-06 13:23)

That doesn't work, there is too much code. I can't make sense of it.
Not sure what to look for.

P#11148 2015-06-06 12:07 ( Edited 2015-06-06 16:07)
if (btn(2)) then mun=mun-1 end
if mun<32 then mun=40 end
P#11153 2015-06-06 18:09 ( Edited 2015-06-06 22:09)
:: neb

I found a way to make a character move on a map and have an animation. here is the code

ben=0
x=0 y=0
function _update()

     if (btn(0)) then x=x-1 end
     if (btn(1)) then x=x+1 end
     if (btn(2)) then y=y-1 end
     if (btn(3)) then y=y+1 end

            if (btn(2)) then ben=ben+1 end
            if ben>2 then ben=0 end

        if (btn(1)) then ben=ben+1 end
            if ben>2 then ben=0 end

            if (btn(0)) then ben=ben+1 end
            if ben>2 then ben=0 end

        if (btn(3)) then ben=ben+1 end
            if ben>2 then ben=0 end
            end

function _draw()
  cls()
  mapdraw(0, 0, 0, 0, 16, 16)
  spr(ben,x,y)
  print(ben)
end
P#11155 2015-06-06 20:26 ( Edited 2015-06-07 00:26)
:: Sagy

thanks :D

P#37063 2017-02-02 06:11 ( Edited 2017-02-02 11:11)

You can detect collisions with either sprite flags (good for environment) or hitboxes (good for actors).
for flags the code is something like

function coll(z)

v = mget(flr(z.x)/8,
flr(z.y)/8+1)
return fget (v,0)

end

here's a thread that explains how better than I can
https://www.lexaloffle.com/bbs/?tid=3116

for hitboxes you first assign actors hitboxes like
b.hitbox={
x=0,y=0,w=1,h=1}
add (p_bullet,b)

then check for collisions like
function hitcol(other,obj)
if
other.x+other.hitbox.x+
other.hitbox.w > obj.x+
obj.hitbox.x and
other.y+other.hitbox.y+
other.hitbox.h > obj.y+
obj.hitbox.y and
other.x+other.hitbox.x
< obj.x+obj.hitbox.x+
obj.hitbox.w and
other.y+other.hitbox.y
< obj.y+obj.hitbox.y+
obj.hitbox.h
then
return true
end
end

the picozone 3 zine has an article called "Dom8verse" that goes into setting up hitboxes.

also be sure to check out the pico8 wiki!

P#37075 2017-02-02 11:42 ( Edited 2017-02-02 16:42)

I threw a Frankenstein cart together if it helps

Cart [#37084#] | 2017-02-02 | License: CC4-BY-NC-SA | Embed

P#37080 2017-02-02 12:50 ( Edited 2017-02-02 18:05)

[Please log in to post a comment]

X
About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2018-12-13 00:24 | 0.028s | 4194k | Q:55