function GAME:sendEntities(ip)
for k, v in pairs(envy.entity.spawned) do
self.server:send("entity", ip);
self.server:send("x:"..v:getX(), ip);
self.server:send("y:"..v:getY(), ip);
self.server:send("a:"..v:getAngle(), ip);
self.server:send("c:"..v:getClass(), ip);
self.server:send("entity", ip);
end;
end;
function GAME.onNetworkReceive(data, ip, port)
if (data == "entity") then
if (GAME.currentEntity) then
if (not GAME.currentEntity.index) then
local entity = envy.entity.add(GAME.currentEntity.class);
-- Set some information about the entity.
entity:setPosition( envy.vector:new(GAME.currentEntity.x, GAME.currentEntity.y) );
entity:setAngle(GAME.currentEntity.angle);
entity:spawn();
elseif ( envy.entity.spawned[GAME.currentEntity.index] ) then
if (GAME.currentEntity.x) then
envy.entity.spawned[GAME.currentEntity.index]:setX(GAME.currentEntity.x);
end;
if (GAME.currentEntity.y) then
envy.entity.spawned[GAME.currentEntity.index]:setY(GAME.currentEntity.y);
end;
if (GAME.currentEntity.angle) then
envy.entity.spawned[GAME.currentEntity.index]:setAngle(GAME.currentEntity.angle);
end;
end;
-- Set the current entity table to nil.
GAME.currentEntity = nil;
else
GAME.currentEntity = {};
end;
elseif (GAME.currentEntity) then
if (string.sub(data, 1, 2) == "x:") then
GAME.currentEntity.x = tonumber( string.sub(data, 3) );
elseif (string.sub(data, 1, 2) == "y:") then
GAME.currentEntity.y = tonumber( string.sub(data, 3) );
elseif (string.sub(data, 1, 2) == "a:") then
GAME.currentEntity.angle = tonumber( string.sub(data, 3) );
elseif (string.sub(data, 1, 2) == "c:") then
GAME.currentEntity.class = string.sub(data, 3);
elseif (string.sub(data, 1, 2) == "i:") then
GAME.currentEntity.index = tonumber( string.sub(data, 3) );
end;
end;
end;
Hehe, apparently Kudomiku is as hyperactive as he is, because he wants to reserve all the cool names for his projects
lg.newImage("cat.png") -- made possible by lg = love.graphics
-- Don't force fullscreen (it frustrates those who want to try your game real quick) -- Develop for 1280x720 (so people can make HD videos)
Meh, can't be arsed to upload it somewhere so I'll post it here xD
For increasing the trace-lib's performance I was working on a line - quadtree today. Here's what it looks like when it's processing the boxes xD
[Phase 11]
* Added envy.util.getSound and envy.util.newMusic and envy.util.getImage.
* Added envy.util.isBetween(value, minimum, maximum).
* Added envy.vector.class:angleBetween(vector).
* Added envy.vector.class:moveTowards(angle, speed).
* Added envy.vector.class:moveAtAngle(angle, speed).
* Added envy.vector.class:rotate(angle).
* Added envy.entity.class:addVelocity(velocity) (adds to the entity's velocity).
* Added envy.entity.include(file).
* Added envy.entity.includeAll(directory).
* Added envy.control.include(file).
* Added envy.control.includeAll(directory).
* Added envy.util.enumerate(directory);
* Added envy.util.include(file);
* Added envy.trace.class:setName(name).
* Added envy.trace.class:getName().
* Added envy.util.reverseTable(base).
* Added anything in game/entities/ is included automatically.
* Added anything in game/controls/ is included automatically.
* Added if you return true on a GAME hook, the normal hooks will not run.
* Added if you return true on a hook, the rest of the hooks will not run.
* Added canTraceHit hook for entities (return false to disallow the trace to hit it).
* Added onInitialize hook for entities.
* Added onHookError hook.
* Added canPressKey and canPressMouse hooks (return false to disallow).
* Added onDrawControls hook.
* Added the envy.control library.
* Added the envy.module library.
* Changed onMousePressed and onMouseReleased arguments to (button, position).
* Changed the way entities work you no longer need to define ENTITY and register it in the file. This is done automatically
when it is included.
Delete your current ËNVY installation before installing the new one! You don't need to delete your game folder!
Kudomiku do you have a function in ENVY that returns the dot product? If not that could be really useful. I'm just starting out with vector math and one thing XNA had was a math.dot function that I used a lot. I can live without it but just a suggestion while your adding other useful stuff.