Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

TIC-80

Fantasy computer for making, playing and sharing tiny games. · By Nesbox

just some coding support

A topic by jackj106 created Nov 14, 2016 Views: 1,622 Replies: 29
Viewing posts 1 to 9

i've been making a random cat game with a cat you can pet.(using 0.0.6, cuz i dunno how to port my stuff to the new version.)

and well, ive tried to make the cat meow, then stop, and then be able to make the meow sound again. dont worry about the variables a through e. they dont matter for this. they just make the cat look like its meowing. basically, i cant seem to figure out how to make it stop playing the meow sound after its done playing it, and then be able to meow after.

heres my code:

--cat



t=0
a=4
b=5
c=20
d=21
e=6
f=0
g=0
p=0



function TIC()

local purr = {}
purr.p = p

if btn(4) then spr(83,0,0,1,1,0) end
if btn(5) then sfx(0,26,square) end
if purr.p < 5 then purr.p = purr.p+1 end
if btn(5) then a=7
b=8
c=23
d=24
e=9
purr.p = purr.p - purr.p
end
if purr.p > 5 then a=4
b=5
c=20
d=21
e=6
sfx()
end

cls(0)
print("blushy cat - pet sim",10,10)
spr(a,104,32,1,2,0)
spr(b,120,32,1,2,0)
spr(c,104,48,1,2,0)
spr(d,120,48,1,2,0)
spr(e,136,32,1,2,0)
t=t+1
end

hope somebody can help :)

thanks,

jackj106

(3 edits)

Yes, I also wonder how to correctly use the sound. (Who needs a demonstration of 3D when you can't understand how to use the sound :/ )

The only thing that I was able to do in this direction is this --> https://www.dropbox.com/s/apw5lwaciox189e/soundtes...

But I warn you, if your sound changed volume/arpeggio/pitch/duty the effect will only work once. (try change volume/arpeggio/pitch/duty for understanding what i mean)

"cuz i dunno how to port my stuff to the new version.":

  • use "GET filename.tic" command: export filename.tic
  • use "ADD" command: to import any .tic file (use this for import my soundtest.tic )

And yes... You can copy your files manually. (C:\Users\YOURUSERNAME\AppData\Roaming\TIC - tiny computer)


Developer (1 edit) (+2)

sfx(id,note,channel)

id [0..63] == -1 by default to stop playing sfx on the channel, so if you call sfx() it means stop playing on 0 channel

note [0..95] we have 8 octaves each has 12 notes

channel [0..3] 0,1-square 2-triangle 3-noise

-- simple note playing demo when a button is pressed
-- sfx(0,44) takes affect only first time, you have to call 'sfx(-1) sfx(0,44)' to reload sfx
t=0
x=104
y=24
function TIC()
 cls(15)
 spr(1+(t%20)/10,x,y,1,4)
 print("Press any arrow key!",64,64,0)
 t=t+1
 if btn(0) then sfx(0,44)
 elseif btn(1) then sfx(0,45)
 elseif btn(2) then sfx(0,46)
 elseif btn(3) then sfx(0,47)
 else sfx(-1) end
end

Also, you can wait until sfx is playing

t=0
x=104
y=24
d=0

function play(note)
 sfx(-1)
 sfx(0,note)

-- wait 30 ticks to start playing new note
 d=30
end

function TIC()
 if d>0 then d=d-1 end
 cls(15)
 spr(1+(t%20)/10,x,y,1,4)
 print("Press any arrow key!",64,64,0)
 t=t+1

 if d==0 then
  if btn(0) then play(44)
  elseif btn(1) then play(45)
  elseif btn(2) then play(46)
  elseif btn(3) then play(47)
  end 
 end

end

So, I'm going to make a sfx demo with the next version then.

Thanks

For the square above the 'press an arrow key' text, what do the individual numbers mean when contributing to its shape and position?

Developer

cls(15) -- means clear screen with thw 15th color (white)
spr(1+(t%20)/10,x,y,1,4) -- draws sprite with index = 1+(t%20)/10, with xy position, 1 means transparent color index, 4 is scale

spr id x y [colorkey [scale [flip]]]

This is awesome it is a perfect clone of Pico-8

Developer

I don't think that TIC is clone of PICO, I just got the idea - all the tools (code,sprite,map,sfx...) in one place to create a complete game without third-party tools, spec is different. They are very similar, but you can't run PICO cart in TIC for example.

(+1)

thank you for the support! I was able to get something working! Will post it when done :)

i am all done with version 0.0.1:https://jackj106.itch.io/blushy-cat-pet-simulator

if you would like the code, just ask.

Developer

Great, the first public game wich is developed on TIC. Thanks

WOW! im really the first? :D amazed.

working on an update and still actively working. :)

what buttons are used for player2?

Developer

first player - ARROWS [Z or ,] [X or .]

second player - RFDG [A] [S]

I'm going to add config tool to map keyboard buttons

(1 edit)

how do you call the player 2 controls in the code? response ASAP pls :)

EDIT: OH GOT A GREAT IDEA! along side the control definer thingy you were talking about, you could add the ability to ADD MORE BUTTONS! (i mean like, within the keyboard.) I think it would be a good addition.

Developer

Just use BTN function with 0-5 index for first player, 8-13 for second player

TIC is designed to play games with joystick/gamepad, touch gamepad on mobile or keyboard. So we have 6 buttons to cover all this devices.

(2 edits)

6 keys it is only if the game is designed for hotseat... If in future versions will add the ability to change key mapping ... If it is possible to adjust the location of the virtual buttons on the android ... If there is an opportunity to show and configure the virtual buttons of the second player on the android device .. . Then we get 6-12 push-button control (single player)... And no more limits on the 6 buttons ¯\_(ツ)_/¯ .

Developer

yes, gamepad data is stored in 16 bit integer, technically you can use BTN func with 0-15 indexes even for single player but I don't recommend to do it. What if user want to use real gamepad to play your game with 16 buttons? add another mapping for gamepads?

So, if you use BTN func with 0-7 indexes for single player game it will cover all platforms without problem I think.

(3 edits)

Minimalism is nice, but within reason. Personally, I believe that the most optimal Number of buttons is 8. (Just like in the NES.)


You have D-pad ("4 buttons"), 2 main buttons (A,B) and 2 additional buttons (select, start).
Games are mainly used only 6 buttons (D-pad + A,B). But if you want, you have two additional buttons. You do not have need to use them, but they are.
At the moment, we have only 6 buttons on one player (Total 12). You are talking about 16 buttons ... But [id: 6,7,14,15]doesn't work at the moment (I checked). And all of my ideas about the use of the 12 keys is just a suggestion how to get around a limit of 6 buttons for a single player game for the current momnet (Of course there are problems with the gamepad. ).

P.S. What if the first player wants to play with the keyboard and the second player with the gamepad? (At the moment this is impossible)
P.P.S. Сustom Key mapping is a great thing. It doesn't matter what it is (Keyboard or a gamepad or the onscreen buttons in the smartphone). I hate when I am forced to use the "Motion Control" with my right hand, and "main buttons" left hand.

Developer

I'm going to add buttons mapping but it will be in personal user settings.

So, you wont configure mapping from the game API just use BTN with [player1:0-7 or player2:8-15]

apon entering this Code, nothing happend when i press ANY button.(EXEPT FOR THE ONES I ALLREADY DEFINED TO DO OTHER TASKS OBIOUSLY)

if btn(8) then print("hello world",10,10) end

Developer

btn(8) mapped to R button, works on my side

WAIT, YOUR RIGHT! :D just dosnt work on 0.0.8, which i was using 2 minutes ago :D

Move "if btn(8) then print("hello world",10,10) end" After "cls(12)" .


cls(12)

if btn(8) then print("hello world",10,10) end

OH I see now.. LOL

are you going to add transparency to the pallete?

Developer
spr id x y [colorkey [scale [flip [rotate]]]]

where 'colorkey' is a transparent color when you draw sprite, -1 by default to draw without transparency

Oh i see. nice to know.

it would be nice to have a transparent "color" you can select in the sprite editor to draw it. :)

how would you insert the data on the map tab into your game?

also there is an issue where if i have nesbox open in another window, i cant type in my browser.

Developer (1 edit)
map [cellx celly cellw cellh [sx sy [colorkey]]]

just use map function, where cellx, celly - world coordinates; cellw, cellh - width and height in cells of map region; sx, sy - screen coordinates to draw map. if you call map() without parameters TIC will draw first screen from the map editor.

map() == map(0,0,30,17,0,0,-1) by default

thanks :)