🤑 Indie game store🙌 Free games😂 Fun games😨 Horror games
👷 Game development🎨 Assets📚 Comics
🎉 Sales🎁 Bundles

Raidez

6
Posts
2
Topics
A member registered 179 days ago

Recent community posts

Can you make the helicopter control more easily like : Space (flight up), Ctrl (flight down), W (forward), S(backward), A/D(rudder), Q/E(lean) ? what do you think ?

where is the secret place at the begining ? it's a fake, just for trolling the player ? XD

Created a new topic Some code snippets

I have a passion to create useless code snippets for me, so I decide to share the most useful for others (or not ;) ).

-- script: moon

export width=240
export height=136
export tilesize=8
export fontsize=6

btnAxis=(a,b)->
    if btn(a) and btn(b)
        return 0
    elseif btn(a)
        return -1
    elseif btn(b)
        return 1
    else
        return 0


class Menu
    new:(x=0,y=0,index=1)=>
        @x=x
        @y=y
        @index=index
        @items={}
    
    add:(text)=>
        table.insert(@items,text)
        
    prev:=>
        i=@index-1
        if i<1
            @index=#@items
        else
            @index=i
    
    next:=>
        i=@index+1
        if i>#@items
            @index=1
        else
            @index=i
    
    draw:(sel="> ",usel="  ",spc=10,col=15)=>
        for k,v in ipairs(@items)
            dy=@y+(k-1)*spc
            if @index==k
                print(sel..v,@x,dy,col)
            else
                print(usel..v,@x,dy,col)


class Spr
    new:(id=0,x=0,y=0,alpha=-1,scale=1,flip=0,rotate=0)=>
        @id=id
        @x=x
        @y=y
        @alpha=alpha
        @scale=scale
        @flip=flip
        @rotate=rotate
    
    draw:=>
        spr(@id,@x,@y,@alpha,@scale,@flip,@rotate)


class RectCollider
    new:(x=0,y=0,w=1,h=1)=>
        @x=x
        @y=y
        @w=w
        @h=h
    
    draw:(col=8)=>
        rectb(@x,@y,@w,@h,col)
    
    collide:(B)=>
        if @x>(B.x+B.w) or (@x+@w-1)<B.x or @y>(B.y+B.h) or (@y+@h-1)<B.y
            return false
        else
            return true


class CircCollider
    new:(x=0,y=0,r=1)=>
        @x=x
        @y=y
        @r=r
    
    draw:(col=8)=>
        circb(@x,@y,@r,col)
    
    collide:(B)=>
        d=(@x-B.x)^2+(@y-B.y)^2
        r=(@r+B.r)^2
        
        if @x>=(B.x-B.r) and @y>=(B.y-B.r)
            r=(@r+B.r+1)^2
        
        if d>r
            return false
        else
            return true
--------------------
cls!
t=Spr(1,104,24,2,4)

export TIC=->
    --update
    t.y+=btnAxis(0,1)
    t.x+=btnAxis(2,3)
    t.id=time()%1000//500+1
    
    --draw
    cls(12)
    t\draw!
    print("HELLO WORLD!",84,64)
Replied to Nesbox in SFX bug

AZERTY, Linux Ubuntu 64bit, TIC 0.16.0 64bit

Replied to Nesbox in SFX bug

Yes, left ALT+1...5 don't work on 0.16.0, they worked on 0.15.0.

Replied to Nesbox in SFX bug

Thanks, but the volume still not working argument. (even if I don't care for my current project ;) )

Posted in SFX bug
(Edited 1 time)

I test that code :

function TIC()
 if btn(0) then
  sfx(0,34,2,5)
 elseif btn(1) then
  sfx(0,34,2,15)
 else
  sfx(-1,0,0)
 end
end

But the sound don't stop and there aren't difference with volume parameter.

Why ? (I use 0.15.0 dev version/same problem on 0.16.0)


Others problems detect on 0.16.0:

shortcuts Alt+1..5 don't work (but F1...5 work fine ;) )

Created a new topic Draw circle function

Sorry for my bad language, I'm french !



I don't see function for drawing circle, so I made it:

function _360(x,y,r,color,fill)
 if not fill then
  for a=1,360,1 do --draw outline only
   dx=math.cos(a)*r+x
   dy=math.sin(a)*r+y
   pix(dx,dy,color)
  end
 else
  for r=r,1,-1 do --draw circle for each radius (for fill circle)
   for a=1,360,1 do
    dx=math.cos(a)*r+x
    dy=math.sin(a)*r+y
    pix(dx,dy,color)
   end
  end
 end
end


function _bresenham(x,y,r,color)
 --see <a href="<a href=" https:="" fr.wikipedia.org="" wiki="" algorithme_de_trac%c3%a9_d%27arc_de_cercle_de_bresenham"=""></a><a href="<a href=" https:="" fr.wikipedia.org="" wiki="" algorithme_de_trac%c.."="">https://fr.wikipedia.org/wiki/Algorithme_de_trac%C...</a>">https://fr.wikipedia.org/wiki/Algorithme_de_trac%C....">https://fr.wikipedia.org/wiki/Algorithme_de_trac%C...
 px=0
 py=r
 m=5-4*r
 
 while(px<=py) do
  pix((px+x),(py+y),color) 
  pix((py+x),(px+y),color)
  pix((-px+x),(py+y),color)
  pix((-py+x),(px+y),color)
  pix((px+x),(-py+y),color)
  pix((py+x),(-px+y),color)
  pix((-px+x),(-py+y),color)
  pix((-py+x),(-px+y),color)
 
  if m>0 then
   py=py-1
   m=m-8*py
  end
 
  px=px+1
  m=m+8*px+4
 end
end


function _andres(x,y,r,color,fill)
 --see <a href="<a href=" https:="" fr.wikipedia.org="" wiki="" algorithme_de_trac%c3%a9_de_cercle_d%27andres"="">https://fr.wikipedia.org/wiki/Algorithme_de_trac%C...</a>">https://fr.wikipedia.org/wiki/Algorithme_de_trac%C...
 px=x
 py=y
 
 d=r-1
 a=r
 --a=r-1
 b=0
 
 while(a>=b) do
  if not fill then
   pix((px+b),(py+a),color)
   pix((px+a),(py+b),color)
   pix((px-b),(py+a),color)
   pix((px-a),(py+b),color)
   pix((px+b),(py-a),color)
   pix((px+a),(py-b),color)
   pix((px-b),(py-a),color)
   pix((px-a),(py-b),color)
  else
   line((px+b),(py-a),(px+b),(py+a),color)
   line((px+a),(py-b),(px+a),(py+b),color)
   line((px-b),(py-a),(px-b),(py+a),color)
   line((px-a),(py-b),(px-a),(py+b),color)
  end
 
  if d>=2*b then
   d=d-2*b-1
   b=b+1
  elseif d<2*(r-a) then
   d=d+2*a-1
   a=a-1
  else
   d=d+2*(a-b-1)
   a=a-1
   b=b+1
  end
 end
end


function _axis(cx,cy,r,color,fill)
 if not fill then
  for y=-r,r,1 do --outline
   for x=-r,r,1 do
    if (x*x+y*y)<=(r*r) then
     pix(cx+x,cy+y,color)
    end
   end
  end
 
  r=r-1
  for y=-r,r,1 do --unfill
   for x=-r,r,1 do
    if (x*x+y*y)<=(r*r) then
     pix(cx+x,cy+y,-1)
    end
   end
  end
 else
  for y=-r,r,1 do
   for x=-r,r,1 do
    if (x*x+y*y)<=(r*r) then
     pix(cx+x,cy+y,color)
    end
   end
  end
 end
end


function circ(x,y,r,color,algo)
 if algo=="360" then
  --don't use it, it's false/incomplete
  --_360(x,y,r,color,true)
 elseif algo=="bresenham" then
  _bresenham(x,y,r,color)
  _andres(x,y,(r),color,true)
 elseif algo=="andres" then
  _andres(x,y,r,color,true)
 elseif algo=="axis" then
  _axis(x,y,r,color,true)
 end
end


function circb(x,y,r,color,algo)
 if algo=="360" then
  --don't use it, it's false/incomplete
  --_360(x,y,r,color,false)
 elseif algo=="bresenham" then
  _bresenham(x,y,r,color)
 elseif algo=="andres" then
  _andres(x,y,r,color,false)
 elseif algo=="axis" then
  _axis(x,y,r,color,false)
 end
end 


There are a lot of algorithm to drawing circle, but after comparison, I suggest to use Andres's method:

function _andres(x,y,r,color,fill)
 --see https://fr.wikipedia.org/wiki/Algorithme_de_trac%C....
 px=x
 py=y
 d=r-1
 a=r
 --a=r-1
 b=0
 while(a>=b) do
  if not fill then
   pix((px+b),(py+a),color)
   pix((px+a),(py+b),color)
   pix((px-b),(py+a),color)
   pix((px-a),(py+b),color)
   pix((px+b),(py-a),color)
   pix((px+a),(py-b),color)
   pix((px-b),(py-a),color)
   pix((px-a),(py-b),color)
  else
   line((px+b),(py-a),(px+b),(py+a),color)
   line((px+a),(py-b),(px+a),(py+b),color)
   line((px-b),(py-a),(px-b),(py+a),color)
   line((px-a),(py-b),(px-a),(py+b),color)
  end
  if d>=2*b then
   d=d-2*b-1
   b=b+1
  elseif d<2*(r-a) then
   d=d+2*a-1
   a=a-1
  else
   d=d+2*(a-b-1)
   a=a-1
   b=b+1
  end
 end
end

function circ(x,y,r,color)
 _andres(x,y,r,color,true)
end

function circb(x,y,r,color)
 _andres(x,y,r,color,false)
end