Elysian Shadows

Meandering.lua

 

Gentle sirs, I present to you:

[size=20]MEANDERING.Lua[/size]

function Meander (chars) 	for i = 1, #chars do  -- # returns the numer of elements in the array, so this loop iterates through the array 		-- MEANDERING AS FUCK 		if chars[i ].entity.transform:getPosition().y <= chars[i ].y1 and chars[i ].entity.transform:getPosition().x >= chars[i ].x1 then 			chars[i ].comp:Move(gyro.Vector2(-90, 0)*deltatime); 		elseif chars[i ].entity.transform:getPosition().x <= chars[i ].x1 and chars[i ].entity.transform:getPosition().y <= chars[i ].y2 then 			chars[i ].comp:Move(gyro.Vector2(0, 90)*deltatime); 		elseif chars[i ].entity.transform:getPosition().y >= chars[i ].y2 and chars[i ].entity.transform:getPosition().x <= chars[i ].x2 then 			chars[i ].comp:Move(gyro.Vector2(90, 0)*deltatime); 		elseif chars[i ].entity.transform:getPosition().x >= chars[i ].x2 and chars[i ].entity.transform:getPosition().y >= chars[i ].y1 then 			chars[i ].comp:Move(gyro.Vector2(0, -90)*deltatime); 		end 	end end function OnLoad() 	-- Adds playable characters to party. 	LuaSingleton:getPartySystem():AddPlayableToParty("TestCharacter1");  	LuaSingleton:getPartySystem():AddPlayableToParty("TestCharacter2"); 	 	-- Sets keyboard input to 'input' and sets player1 to active character. 	input = LuaSingleton:getInput(); 	player1 = LuaSingleton:getPartySystem():getPlayablePartyMember(0); 	 	-- Grabs entities from .txt 	fuckbritches = Entity:getByName("Fuckbritches"); 	doucheass = Entity:getByName("Doucheass"); 	assdouche = Entity:getByName("Assdouche"); 	 	-- Fucking embeded Lua tables... Goddamn. 	meanderingChars = { 		{ 			entity = Entity:getByName("Fuckbritches"),  -- Entity name 			comp = fuckbritches:getCharacter(),       -- Sets character component 			x1 = 700, -- Original position from Entity.txt 			y1 = 320, --/ 			x2 = 963, -- 			y2 = 400  -- Perimeter boundry coord 		}, 		{ 			entity = Entity:getByName("Doucheass"), 			comp = doucheass:getCharacter(), 			x1 = 340, 			y1 = 360, 			x2 = 479, 			y2 = 587 		}, 		{ 			entity = Entity:getByName("Assdouche"),  			comp = assdouche:getCharacter(), 			x1 = 300, 			y1 = 340, 			x2 = 490, 			y2 = 380 		} 	} 	print("FUUUUCKING LOADED!!nn"); end function Update() 	deltatime = LuaSingleton:getTimerSystem():getDeltaTime();  -- sets delta time, all the time, everytime 	if input:getDown(input.BUT_F) then -- random ass debugging shit, hit F to see player1's X and Y location 		print(player1.transform:getPosition().x .. " " .. player1.transform:getPosition().y .. "n"); end Meander(meanderingChars); -- calls Meander while passing the embeded mistakery end 

In this script I emulated an array of classes in Lua's (embedded) table data type. In this embedded table I was able to create a general entity name, call the character component, create an X/Y origin, X/Y pathing boundry in preparation to tell these assholes to get to steppin'.

The meander function is called every frame (via Update() ) and moves the entities around the perimeter I have set using their original X/Y position and the second X/Y coordinate defined in the table. Because I am using

Chars[i ].comp:Move(gyro.Vector2(X,Y)*deltatime);

Not only is the sprite animated, but it also framerate independent and moves at the correct speed no matter how shitty your console (or computer) might be.

Also... [size=20]SOUND WORKS[/size]

http://www.youtube.com/watch?v=Efoy2EH8B_E

Questions, comments?

Falco Girgis
Falco Girgis is the founder and lead software architect of the Elysian Shadows project. He was previously employed in the telecom industry before taking a chance on Kickstarter and quitting his job to live the dream. He is currently pursuing his masters in Computer Engineering with a focus on GPU architecture.