PicoPicoGameEngine

Quick Links

Others

pphitcheck()

{
  x=[],
  y=[],
  hitmask=[],
  hitlength=[],
  hitcenter=[]
}

{
  x=[],
  y=[],
  hitmask=[],
  hitrect=[]
}
pphitcheck( a_group, b_group, function(a,b) ... end)
a_group : object

b_group : object

a : object

b : object

--use length check
pptex:default(
  pptex:load("sample.png"))
rand=math.random
c = pppoint(16,16)
g = ppgraph

enemy = ppsprite.new(10)
for k,v in pairs(enemy) do
  v.x = rand(0,10)*32
  v.y = rand(0,10)*32
  v.hitmask = 1
  v.hitlength = 8
  v.hitcenter = c
  v:tile(3)
  ppgraph:append(v)
end

player = ppsprite.new()
p = player
p.x = 100
p.y = 100
p.hitmask = 1
p.hitlength = 8
p.hitcenter = c
p:tile(2)
ppgraph:append(p)

function start()
  player:drag(pptouch())
  pphitcheck(
    enemy,
    {player},
    function(a,b)
      g:print("HIT!")
    end
  )
end
--use rectangle check
pptex:default(
  pptex:load("sample.png"))
rand=math.random
r = pprect(0,0,32,32)
g = ppgraph

enemy = ppsprite.new(10)
for k,v in pairs(enemy) do
  v.x = rand(0,10)*32
  v.y = rand(0,10)*32
  v.hitmask = 1
  v.hitrect = r
  v:tile(3)
  ppgraph:append(v)
end

player = ppsprite.new()
p = player
p.x = 100
p.y = 100
p.hitmask = 1
p.hitrect = r
p:tile(2)
ppgraph:append(p)

function start()
  player:drag(pptouch())
  pphitcheck(
    enemy,
    {player},
    function(a,b)
      g:print("HIT!")
    end
  )
end

ppforeach()

ppforeach( array, function(index,value) ... end)
array : object

index : number

value : object

pplength()

len = pplength(point1,point2)
point1 : point object

point2 : point object

len : number

pptouch()

touch = pptouch()
touch : object

g=ppgraph
function start()
  t=pptouch()
  for k,v in pairs(t) do
    g:print(
      k..":"..
      "X="..v.x..
      ",Y="..v.y)
    g:move(0,16)
  end
end

point object

position={
  x=[x position],
  y=[y position]
}

rectangle object

rect={
  x=[x position],
  y=[y position],
  width=[width],
  height=[height]
}

color object

color={
  r=[red 0 - 255],
  g=[green 0 - 255],
  b=[blue 0 - 255],
  a=[alpha 0 - 255],
}