Sketching simulations in TIC80: Difference between revisions
No edit summary |
No edit summary |
||
(9 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== aka How to import an animated baby... == | |||
trying to find characters 16x16 | trying to find characters 16x16 | ||
Line 4: | Line 6: | ||
https://opengameart.org/content/tiny-16-basic | https://opengameart.org/content/tiny-16-basic | ||
[[File:Gimp characters with grid.png]] | |||
In Gimp: Image > Configure Grid, then View > Show Grid | |||
TIC can import GIFs (with 16 color palette) @ 128x256 | |||
[[File:Addbabygif.png]] | |||
[[File:Babytic.png]] | |||
== 03 == | |||
<source lang="lua"> | |||
-- title: game title | |||
-- author: game developer | |||
-- desc: short description | |||
-- script: lua | |||
t=0 | |||
BABY_MOVE_DOWN={32,34,36,34} | |||
BABY_MOVE_LEFT={64,66,68,66} | |||
BABY_MOVE_RIGHT={96,98,100,98} | |||
BABY_MOVE_UP={128,130,132,130} | |||
DIR={ | |||
UP=0, | |||
RIGHT=1, | |||
DOWN=2, | |||
LEFT=3 | |||
} | |||
baby={ | |||
sprite=32, | |||
anim=nil, | |||
dir=DIR.RIGHT, | |||
sw=2, | |||
sh=2, | |||
x=0, | |||
y=0 | |||
} | |||
function TIC() | |||
baby.anim=nil | |||
if btn(0) then | |||
baby.y=baby.y-1 | |||
baby.anim=BABY_MOVE_UP | |||
baby.dir=DIR.UP | |||
end | |||
if btn(1) then | |||
baby.y=baby.y+1 | |||
baby.anim=BABY_MOVE_DOWN | |||
baby.dir=DIR.DOWN | |||
end | |||
if btn(2) then | |||
baby.x=baby.x-1 | |||
baby.anim=BABY_MOVE_LEFT | |||
baby.dir=DIR.LEFT | |||
end | |||
if btn(3) then | |||
baby.x=baby.x+1 | |||
baby.anim=BABY_MOVE_RIGHT | |||
baby.dir=DIR.RIGHT | |||
end | |||
cls(13) | |||
spr( | |||
baby.sprite, | |||
baby.x,baby.y, | |||
0, -- colorkey | |||
1,0,0, --- scale,flip,rotate | |||
baby.sw,baby.sh -- width,height | |||
) | |||
updateBaby() | |||
print("HELLO WORLD!",84,84) | |||
t=t+1 | |||
end | |||
function updateBaby() | |||
if baby.anim then | |||
-- from panda:1427 | |||
baby.sprite=baby.anim[1+(time()//256)%#baby.anim] | |||
-- trace("baby"..baby.sprite) | |||
else | |||
if baby.dir==DIR.UP then | |||
baby.sprite=BABY_MOVE_UP[2] | |||
elseif baby.dir==DIR.RIGHT then | |||
baby.sprite=BABY_MOVE_RIGHT[2] | |||
elseif baby.dir==DIR.DOWN then | |||
baby.sprite=BABY_MOVE_DOWN[2] | |||
else | |||
baby.sprite=BABY_MOVE_LEFT[2] | |||
end | |||
end | |||
end | |||
-- <TILES> | |||
-- 032:00000000000000340000034c0000044400000444000004040000040c00000044 | |||
-- 033:0000000043000000c4300000444000004440000040400000c040000044000000 | |||
-- 034:00000000000000340000034c0000044400000444000004040000040c00000044 | |||
-- 035:0000000043000000c4300000444000004440000040400000c040000044000000 | |||
-- 036:00000000000000340000034c0000044400000444000004040000040c00000044 | |||
-- 037:0000000043000000c4300000444000004440000040400000c040000044000000 | |||
-- 048:0000342300004344000000440000004200000044000ee0c4000ee0220000ee00 | |||
-- 049:3240000044c40000440400002200000002300000000ee0000eeee000eeee0000 | |||
-- 050:0000042200004344000040440000004300000042000ee042000eee000000eeee | |||
-- 051:2240000044340000440400003400000024000000240ee00000eee000eeee0000 | |||
-- 052:0000042300004c44000040440000002200000320000ee000000eeee00000eeee | |||
-- 053:32430000443400004400000024000000440000004c0ee000220ee00000ee0000 | |||
-- 064:00000000000000340000034c00000444000004440000040400000c0400000244 | |||
-- 065:0000000043000000c43000004440000044400000443000003330000033200000 | |||
-- 066:00000000000000340000034c00000444000004440000040400000c0400000244 | |||
-- 067:0000000043000000c43000004440000044400000443000003330000033200000 | |||
-- 068:00000000000000340000034c00000444000004440000040400000c0400000244 | |||
-- 069:0000000043000000c43000004440000044400000443000003330000033200000 | |||
-- 080:0000002300000044000004c20000043000000003000e0220000e00000000eeee | |||
-- 081:32000000430000003300000033000000430000004440e0000c30e000e00e0000 | |||
-- 082:0000000300000004000000040000000400000000000eee04000eee0c0000ee00 | |||
-- 083:3200000040000000c0000000300000000000000040eee00030eee00000ee0000 | |||
-- 084:0000002300003034000000340000003400000044000e0344000e03c30000e000 | |||
-- 085:32000000440000000c40000003400000300000000220e000000ee000eeee0000 | |||
-- 096:00000000000000340000034c0000044400000444000003440000033300000233 | |||
-- 097:0000000043000000c430000044400000444000004040000040c0000044200000 | |||
-- 098:00000000000000340000034c0000044400000444000003440000033300000233 | |||
-- 099:0000000043000000c430000044400000444000004040000040c0000044200000 | |||
-- 100:00000000000000340000034c0000044400000444000003440000033300000233 | |||
-- 101:0000000043000000c430000044400000444000004040000040c0000044200000 | |||
-- 112:0000002300000044000004c00000043000000003000e0220000ee0000000eeee | |||
-- 113:32000000430300004300000043000000440000004430e0003c30e000000e0000 | |||
-- 114:00000023000000040000000c0000000300000000000eee04000eee030000ee00 | |||
-- 115:300000004000000040000000400000000000000040eee000c0eee00000ee0000 | |||
-- 116:0000002300000034000000330000003300000034000e0444000e03c00000000e | |||
-- 117:32000000440000002c40000003400000300000000220e0000000e000eeee0000 | |||
-- 128:00000000000000340000034c0000044400000444000004440000034400000033 | |||
-- 129:0000000043000000c43000004440000044400000444000004430000033000000 | |||
-- 130:00000000000000340000034c0000044400000444000004440000034400000033 | |||
-- 131:0000000043000000c43000004440000044400000444000004430000033000000 | |||
-- 132:00000000000000340000034c0000044400000444000004440000034400000033 | |||
-- 133:0000000043000000c43000004440000044400000444000004430000033000000 | |||
-- 144:0000342300004034000000440000003200000033000ee044000ee0220000ee00 | |||
-- 145:3240000043c40000440400002200000002300000000ee0000eeee000eeee0000 | |||
-- 146:0000042300004334000040440000002300000032000ee042000eee000000eeee | |||
-- 147:3240000043340000440400003200000023000000240ee00000eee000eeee0000 | |||
-- 148:0000042300004c34000040440000002200000320000ee000000eeee00000eeee | |||
-- 149:3243000043040000440000002300000033000000440ee000220ee00000ee0000 | |||
-- </TILES> | |||
-- <SPRITES> | |||
-- 240:00000000000000000000000000000000000000000000000000000000cccccccc | |||
-- 241:00000000000000000000000000000000000000000000000000000000cccccccc | |||
-- 242:00000000000000000000000000000000000000000000000000000000cccccccc | |||
-- 243:00000000000000000000000000000000000000000000000000000000cccccccc | |||
-- 244:00000000000000000000000000000000000000000000000000000000cccccccc | |||
-- 245:00000000000000000000000000000000000000000000000000000000cccccccc | |||
-- 246:00000000000000000000000000000000000000000000000000000000cccccccc | |||
-- 247:00000000000000000000000000000000000000000000000000000000cccccccc | |||
-- 248:00000000000000000000000000000000000000000000000000000000cccccccc | |||
-- 249:00000000000000000000000000000000000000000000000000000000cccccccc | |||
-- 250:00000000000000000000000000000000000000000000000000000000cccccccc | |||
-- 251:00000000000000000000000000000000000000000000000000000000cccccccc | |||
-- 252:00000000000000000000000000000000000000000000000000000000cccccccc | |||
-- 253:00000000000000000000000000000000000000000000000000000000cccccccc | |||
-- 254:00000000000000000000000000000000000000000000000000000000cccccccc | |||
-- 255:00000000000000000000000000000000000000000000000000000000cccccccc | |||
-- </SPRITES> | |||
-- <WAVES> | |||
-- 000:00000000ffffffff00000000ffffffff | |||
-- 001:0123456789abcdeffedcba9876543210 | |||
-- 002:0123456789abcdef0123456789abcdef | |||
-- </WAVES> | |||
-- <SFX> | |||
-- 000:000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000304000000000 | |||
-- </SFX> | |||
-- <PALETTE> | |||
-- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57 | |||
-- </PALETTE> | |||
</source> | |||
[[Category:TIC80]] |
Latest revision as of 13:23, 8 February 2021
aka How to import an animated baby...
trying to find characters 16x16
https://opengameart.org/content/zelda-like-tilesets-and-sprites
https://opengameart.org/content/tiny-16-basic
In Gimp: Image > Configure Grid, then View > Show Grid
TIC can import GIFs (with 16 color palette) @ 128x256
03
-- title: game title
-- author: game developer
-- desc: short description
-- script: lua
t=0
BABY_MOVE_DOWN={32,34,36,34}
BABY_MOVE_LEFT={64,66,68,66}
BABY_MOVE_RIGHT={96,98,100,98}
BABY_MOVE_UP={128,130,132,130}
DIR={
UP=0,
RIGHT=1,
DOWN=2,
LEFT=3
}
baby={
sprite=32,
anim=nil,
dir=DIR.RIGHT,
sw=2,
sh=2,
x=0,
y=0
}
function TIC()
baby.anim=nil
if btn(0) then
baby.y=baby.y-1
baby.anim=BABY_MOVE_UP
baby.dir=DIR.UP
end
if btn(1) then
baby.y=baby.y+1
baby.anim=BABY_MOVE_DOWN
baby.dir=DIR.DOWN
end
if btn(2) then
baby.x=baby.x-1
baby.anim=BABY_MOVE_LEFT
baby.dir=DIR.LEFT
end
if btn(3) then
baby.x=baby.x+1
baby.anim=BABY_MOVE_RIGHT
baby.dir=DIR.RIGHT
end
cls(13)
spr(
baby.sprite,
baby.x,baby.y,
0, -- colorkey
1,0,0, --- scale,flip,rotate
baby.sw,baby.sh -- width,height
)
updateBaby()
print("HELLO WORLD!",84,84)
t=t+1
end
function updateBaby()
if baby.anim then
-- from panda:1427
baby.sprite=baby.anim[1+(time()//256)%#baby.anim]
-- trace("baby"..baby.sprite)
else
if baby.dir==DIR.UP then
baby.sprite=BABY_MOVE_UP[2]
elseif baby.dir==DIR.RIGHT then
baby.sprite=BABY_MOVE_RIGHT[2]
elseif baby.dir==DIR.DOWN then
baby.sprite=BABY_MOVE_DOWN[2]
else
baby.sprite=BABY_MOVE_LEFT[2]
end
end
end
-- <TILES>
-- 032:00000000000000340000034c0000044400000444000004040000040c00000044
-- 033:0000000043000000c4300000444000004440000040400000c040000044000000
-- 034:00000000000000340000034c0000044400000444000004040000040c00000044
-- 035:0000000043000000c4300000444000004440000040400000c040000044000000
-- 036:00000000000000340000034c0000044400000444000004040000040c00000044
-- 037:0000000043000000c4300000444000004440000040400000c040000044000000
-- 048:0000342300004344000000440000004200000044000ee0c4000ee0220000ee00
-- 049:3240000044c40000440400002200000002300000000ee0000eeee000eeee0000
-- 050:0000042200004344000040440000004300000042000ee042000eee000000eeee
-- 051:2240000044340000440400003400000024000000240ee00000eee000eeee0000
-- 052:0000042300004c44000040440000002200000320000ee000000eeee00000eeee
-- 053:32430000443400004400000024000000440000004c0ee000220ee00000ee0000
-- 064:00000000000000340000034c00000444000004440000040400000c0400000244
-- 065:0000000043000000c43000004440000044400000443000003330000033200000
-- 066:00000000000000340000034c00000444000004440000040400000c0400000244
-- 067:0000000043000000c43000004440000044400000443000003330000033200000
-- 068:00000000000000340000034c00000444000004440000040400000c0400000244
-- 069:0000000043000000c43000004440000044400000443000003330000033200000
-- 080:0000002300000044000004c20000043000000003000e0220000e00000000eeee
-- 081:32000000430000003300000033000000430000004440e0000c30e000e00e0000
-- 082:0000000300000004000000040000000400000000000eee04000eee0c0000ee00
-- 083:3200000040000000c0000000300000000000000040eee00030eee00000ee0000
-- 084:0000002300003034000000340000003400000044000e0344000e03c30000e000
-- 085:32000000440000000c40000003400000300000000220e000000ee000eeee0000
-- 096:00000000000000340000034c0000044400000444000003440000033300000233
-- 097:0000000043000000c430000044400000444000004040000040c0000044200000
-- 098:00000000000000340000034c0000044400000444000003440000033300000233
-- 099:0000000043000000c430000044400000444000004040000040c0000044200000
-- 100:00000000000000340000034c0000044400000444000003440000033300000233
-- 101:0000000043000000c430000044400000444000004040000040c0000044200000
-- 112:0000002300000044000004c00000043000000003000e0220000ee0000000eeee
-- 113:32000000430300004300000043000000440000004430e0003c30e000000e0000
-- 114:00000023000000040000000c0000000300000000000eee04000eee030000ee00
-- 115:300000004000000040000000400000000000000040eee000c0eee00000ee0000
-- 116:0000002300000034000000330000003300000034000e0444000e03c00000000e
-- 117:32000000440000002c40000003400000300000000220e0000000e000eeee0000
-- 128:00000000000000340000034c0000044400000444000004440000034400000033
-- 129:0000000043000000c43000004440000044400000444000004430000033000000
-- 130:00000000000000340000034c0000044400000444000004440000034400000033
-- 131:0000000043000000c43000004440000044400000444000004430000033000000
-- 132:00000000000000340000034c0000044400000444000004440000034400000033
-- 133:0000000043000000c43000004440000044400000444000004430000033000000
-- 144:0000342300004034000000440000003200000033000ee044000ee0220000ee00
-- 145:3240000043c40000440400002200000002300000000ee0000eeee000eeee0000
-- 146:0000042300004334000040440000002300000032000ee042000eee000000eeee
-- 147:3240000043340000440400003200000023000000240ee00000eee000eeee0000
-- 148:0000042300004c34000040440000002200000320000ee000000eeee00000eeee
-- 149:3243000043040000440000002300000033000000440ee000220ee00000ee0000
-- </TILES>
-- <SPRITES>
-- 240:00000000000000000000000000000000000000000000000000000000cccccccc
-- 241:00000000000000000000000000000000000000000000000000000000cccccccc
-- 242:00000000000000000000000000000000000000000000000000000000cccccccc
-- 243:00000000000000000000000000000000000000000000000000000000cccccccc
-- 244:00000000000000000000000000000000000000000000000000000000cccccccc
-- 245:00000000000000000000000000000000000000000000000000000000cccccccc
-- 246:00000000000000000000000000000000000000000000000000000000cccccccc
-- 247:00000000000000000000000000000000000000000000000000000000cccccccc
-- 248:00000000000000000000000000000000000000000000000000000000cccccccc
-- 249:00000000000000000000000000000000000000000000000000000000cccccccc
-- 250:00000000000000000000000000000000000000000000000000000000cccccccc
-- 251:00000000000000000000000000000000000000000000000000000000cccccccc
-- 252:00000000000000000000000000000000000000000000000000000000cccccccc
-- 253:00000000000000000000000000000000000000000000000000000000cccccccc
-- 254:00000000000000000000000000000000000000000000000000000000cccccccc
-- 255:00000000000000000000000000000000000000000000000000000000cccccccc
-- </SPRITES>
-- <WAVES>
-- 000:00000000ffffffff00000000ffffffff
-- 001:0123456789abcdeffedcba9876543210
-- 002:0123456789abcdef0123456789abcdef
-- </WAVES>
-- <SFX>
-- 000:000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000304000000000
-- </SFX>
-- <PALETTE>
-- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57
-- </PALETTE>