i can't post the entire love, it has become pretty big
but here is the lua for the class creation:
Code: Select all
require("AnAL")
require("moves")
--generic class
player={xcoord=200,ycoord=350}
npctable={}
--table for player types
types={"worm","kota","gria","bazelos","gauros"}
--RULES FOR SPRITES AND ANIMATIONS
--INDEX ANIMATION
--1 STANDING
--2 INBETWEEN
--3 TURNING
--4 WALKING
--5 JUMP
--6 DUCK
--7 DUCKINV
--8 PUNCH
--9 ROLL
--10 RUN
--11 KICK
--12 HAKI
--create metatable for prototypes
player.__index=player
--create new player method
function player:new(type)
local self={}
setmetatable(self,player)
if type==types[1] then
self.sprites={
createsprite("chars/worm/wormstanding.png"),
createsprite("chars/worm/worminbetween.png"),
createsprite("chars/worm/wormturning.png"),
createsprite("chars/worm/worm.png"),
createsprite("chars/worm/wormjumpingnew.png"),
createsprite("chars/worm/wormducking.png"),
createsprite("chars/worm/worminvertducking.png"),
createsprite("chars/worm/wormpunch01.png"),
createsprite("chars/worm/wormrolling.png"),
createsprite("chars/worm/wormrunning.png"),
createsprite("chars/worm/wormkick01.png"),
createsprite("chars/worm/wormjumphaki.png"),
createsprite("chars/worm/wormcrawling.png"),
createsprite("chars/worm/wormvanish.png")
}
self.animations={
newAnimation(self.sprites[1],64,64,0.09,8),
newAnimation(self.sprites[2],64,64,0.5,3),
newAnimation(self.sprites[3],64,64,0.5,5),
newAnimation(self.sprites[4],64,64,0.5,12),
newAnimation(self.sprites[5],64,64,1,15),
newAnimation(self.sprites[6],64,64,0.5,5),
newAnimation(self.sprites[7],64,64,0.5,5),
newAnimation(self.sprites[8],100,100,0.5,7),
newAnimation(self.sprites[9],64,64,0.5,13),
newAnimation(self.sprites[10],64,64,0.5,4),
newAnimation(self.sprites[11],64,64,0.5,10),
newAnimation(self.sprites[12],64,64,0.5,23),
newAnimation(self.sprites[13],64,64,0.5,5),
newAnimation(self.sprites[14],64,64,0.5,8)
}
self.mass=10
self.yvel=10
self.speed=7
function self:draw()
love.graphics.print("drawingfunction",750,200)
end
elseif type==types[2] then
self.sprites={
createsprite("chars/kota/kotastanding.png")
}
self.animations={
newAnimation(self.sprites[1],64,64,0.5,9)
}
function self:draw()
kota_draw(self)
end
end
self.states={
freefall=1,
face=1,
walking=0,
standing=0,
turning=0,
duck=0,
jump=0,
roll=0,
attack=0,
landing=0,
running=0,
haki=0,
stall=0,
lose=0,
death=0,
crawl=0
}
return self
end
function npc_create(name,type)
name=player:new(type)
table.insert(npctable,name)
end
function createsprite(path)
return love.graphics.newImage(path)
end
function kota_draw(name)
stand(name,name.facestate)
end
here is the stand function alone:
Code: Select all
function stand(name,orientation)
inbetweenstatus=0
duckstatus=0
turningstatus=0
name.standingstate=1
name.inbetweenstate=0
name.turningstate=0
name.walkingstate=0
name.states.haki=0
afunc="stand"
if orientation==1 then
name.animations[1]:draw(name.xcoord,name.ycoord,0,orientation,1)
else
name.animations[1]:draw(name.xcoord+64,name.ycoord,0,orientation,1)
end
love.graphics.print("STANDING",300,30)
for i=2,14,1 do
if name.animations[i] then
name.animations[i]:reset()
end
end
end
and it is called simultaenously
for the player character as a stand(worm,worm.states.face)
and after initializing an npc character npc1=player:new("kota")
with npc1:draw() which ends to stand(npc1,npc1.states.face)
stand function seems that it cannot handle two simultaenous calls....
Edit: Now that i am thinking it clearer, the function is indeed called simultaenously for both characters... i think i need to find a way to call it once for every character:
Enter all my characters in a table and iterate the table to execute the standing function for every character on the scene, one by one...
Am I correct or am i missing somethin?
Edit2: I solved it with the second way, i also needed to correct some variable names on the stand function
.
Everything back on smoooooooooooooooooooth again