fuzzy love

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
ishkabible
Party member
Posts: 241
Joined: Sat Oct 23, 2010 7:34 pm
Location: Kansas USA

fuzzy love

Post by ishkabible » Sat Dec 04, 2010 6:45 pm

ok so i haven't started this but im considering using the love sources and embedding Squirrel instead of Lua. Squirrel is a new language that is object oriented and promotes it's self as a language to make games with. it was somewhat based off of Lua but has a number of difference. these differences are beneficial to making games so ill list a few of it's features that may(depending on how you make your game) make making games much easier and funner.

*Squirrel has arrays, Lua doesn't. the arrays work like vectors in c++ and are much better suited for buffers. in my zombie game i make heavy use of buffers for updating the zombies and particles and various other things. this would make my game run much faster. it also has a sorting function that allows you to sort though huge arrays almost as quickly as in c++. i sort though sprites by distance in my zombie game to determine witch should be effected by bullet, faster sorting algorithm means faster game.

*Squirrel has a defined way to write classes, Lua doesn't. we all use some type of OO in love becuase it's just plain necessary to make games. a defined clean way to make classes is a huge benefit in my opinion. they still work the same way (have meta-methods, use tables so O.x is O["x"]) but there is a defined way do it plus it's cleaner. it has constructors which make initializing objects much easier and cleaner.

it's a rather new language but it seems very promising to me. i know it's control flow is much slower than in Lua and it's knowledge base is no were near that of Lua. there a number of cons but i still think it's very promising. looking to see what others think about it.

User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: fuzzy love

Post by Robin » Sat Dec 04, 2010 7:05 pm

Interesting. I hope you succeed, although I won't be following this myself.
ishkabible wrote:*Squirrel has arrays, Lua doesn't. the arrays work like vectors in c++ and are much better suited for buffers. in my zombie game i make heavy use of buffers for updating the zombies and particles and various other things. this would make my game run much faster. it also has a sorting function that allows you to sort though huge arrays almost as quickly as in c++. i sort though sprites by distance in my zombie game to determine witch should be effected by bullet, faster sorting algorithm means faster game.
Optimisation is vastly overrated. The order of complexity is much more important than byte-shuffling (or, god forbid, bit-shuffling) if you want your games to be faster than Windows.
ishkabible wrote:i know it's control flow is much slower than in Lua
Ironic for such a speed freak. :P
Help us help you: attach a .love.

User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: fuzzy love

Post by zac352 » Sat Dec 04, 2010 7:56 pm

I would like this, I mean Squirrel is one of my favourite languages, but I have little experience with it. The reason being it doesn't have many bindings. I hope you get a version out soon. :awesome:
Hello, I am not dead.

User avatar
Mud
Citizen
Posts: 98
Joined: Fri Nov 05, 2010 4:54 am

Re: fuzzy love

Post by Mud » Sat Dec 04, 2010 8:36 pm

ishkabible wrote:Squirrel has arrays, Lua doesn't.
Lua has arrays, it just doesn't use a special language construct for them. If you use a table as an array, internally it is an array. Every table has an array and a hashtable portion (if you never use one portion, it's never even allocated). See the last two lines:

Code: Select all

typedef struct Table {
  CommonHeader;
  lu_byte flags;  /* 1<<p means tagmethod(p) is not present */ 
  lu_byte lsizenode;  /* log2 of size of `node' array */
  struct Table *metatable;
  Node *node;
  Node *lastfree;  /* any free position is before this position */
  GCObject *gclist;
  TValue *array;  /* array part */
  int sizearray;  /* size of 'array' array */
} Table;
Lua seamlessly interoperates between these two.

var = { x=10, y=40, "this", "is", "a", "test" }

This table has two hashtable entries and four array entries, the latter of which are stored in a good-old-fashion C array.

User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: fuzzy love

Post by TechnoCat » Sat Dec 04, 2010 8:38 pm

I've been wanting to try out Squirrel for a while now. Replacing Lua with Squirrel in Love would be an awesome way to learn it.

User avatar
ishkabible
Party member
Posts: 241
Joined: Sat Oct 23, 2010 7:34 pm
Location: Kansas USA

Re: fuzzy love

Post by ishkabible » Sat Dec 04, 2010 8:53 pm

alright ill start working on it. first i have to get love to compile then comes the gruelingly long task of switching out all the Lua functions with Squirrel functions :| . by the way just to clarify why having a separate construct for arrays in the language is better(in this case) than in lua is becuase of speed. i made a radix sorting algorithm in lua and in Squirrel to see how much faster the Squirrel arrays where than lua and it was by orders of magnitude. take the two scripts.
(console applications)

Code: Select all

math.randomseed(os.time())
Bucket = {}
mt = {}
function Bucket:new()
	return setmetatable({size=0,data={}},mt)
end
function Bucket:push_front(val)
	table.insert(self.data,0,val)
	self.size = self.size + 1
end
function Bucket:pop_back()
	self.size = self.size - 1
end
function Bucket:back()
	return self.data[self.size-1]
end
mt.__index = function(t,key)
				if type(key) == "number" then
					return t.data[key]
				else
					return Bucket[key]
				end
			 end
mt.__newindex = function(t,key,value)
					error(key.." is not a part of class Bucket")
				end

local function L2GRadixSort(SL)
	local Buckets = {Bucket:new(),Bucket:new(),Bucket:new(),Bucket:new(),Bucket:new(),Bucket:new(),Bucket:new(),Bucket:new(),Bucket:new(),Bucket:new()}
	Buckets[0] = Bucket:new()
	local Size = SL.size
	local Bucket_0_Size=0
	local i=0,x
	while not (Bucket_0_Size == Size) do
		for j=0,Size-1,1 do
			Buckets[math.floor((SL[j]/(10^i))%10)]:push_front(SL[j])
		end
		Bucket_0_Size = Buckets[0].size
		x = 0
		for j=0,9,1 do
			local Bucket_Size = Buckets[j].size
			for k=0,Bucket_Size-1,1 do
				SL[x] = Buckets[j]:back()
				x=x+1
				Buckets[j]:pop_back()
			end
		end
		i=i+1
	end
end

local UnSorted = {}
UnSorted.size = 0
for i=0,100000,1 do
	UnSorted[i] = math.random(100)
	UnSorted.size = UnSorted.size + 1
end
local start = os.time()
L2GRadixSort(UnSorted)
local finish = os.time()
print(finish-start)
--[[for i=1,UnSorted.size-1,1 do
	print(UnSorted[i])
end]]
os.execute("pause>nul")

Code: Select all

function L2GRadixSort(SL) {
	local Size = SL.len();
	local Buckets = array(256,null);
	foreach(i,val in Buckets) {
		Buckets[i] = [];
	}
	local BucketSize;
	local Bucket_0_Size = 0;
	local j=0,k=0,i=0,x=0;
	for(;Bucket_0_Size!=Size;++i) {
		j=0;
		do {
			Buckets[(SL[j]>>(i*8))%256].push(SL[j]);
			++j;
		} while(j<Size);
		Bucket_0_Size = Buckets[0].len();
		j=0;
		x=0;
		do {
			BucketSize = Buckets[j].len();
			for(k=0;k<BucketSize;++k) {
				SL[x++] = Buckets[j][0];
				Buckets[j].remove(0);
			}
		} while(++j<256);
	}
}

function gen_random(seed,max) {
	local last=seed
	local IM = 139968;
	local IA = 3877;
	local IC = 29573;
	for(;;) {  //loops forever
		yield (max * (last = (last * IA + IC) % IM) / IM);
	}
}
local randtor = gen_random(42,1000000);
local test = [];
test.resize(100000);
for(local i=0;i<100000;++i) {
	local x = resume randtor;
	test[i] = (x<0)?(-x):(x);
}
print("\n");

L2GRadixSort(test);

for(local i=0;i<10;++i) {
	print(test[i]+"\n");
}

obviously this is not a direct comparison becuase such things are impossible but it shows the capability and speed of Squirrel's arrays. a useful thing i left out was integers. it has integers as well as floats vs Lua witch just has doubles witch it checks to see weather or not is an integer then indexing that if it can so 2.1 would be used with a table but 2 would be used with an array. this whole process works well and all but it's not as fast as straight up arrays with straight up integers. also there are a number of other things like bit-wise operators, increment, deincrement that add to the power of the language.
Last edited by ishkabible on Sat Dec 04, 2010 8:55 pm, edited 1 time in total.

User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: fuzzy love

Post by zac352 » Sat Dec 04, 2010 8:55 pm

TechnoCat wrote:I've been wanting to try out Squirrel for a while now. Replacing Lua with Squirrel in Love would be an awesome way to learn it.
I'd like to do a few projects with it, but I believe that my engine is to far in for that. :(
Idk. Diablo has a long way to go on those sprites... He has yet to do anything in the past 2 weeks. xD
Hello, I am not dead.

User avatar
ishkabible
Party member
Posts: 241
Joined: Sat Oct 23, 2010 7:34 pm
Location: Kansas USA

Re: fuzzy love

Post by ishkabible » Sat Dec 04, 2010 9:21 pm

where can i get the sources for 0.7, all i can find is 0.68?

edit: ok i found the linux sources for 0.7, i assume these will compile on windows as well right? im gona try until someone tells me this wont work and why.

User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: fuzzy love

Post by bartbes » Sat Dec 04, 2010 9:37 pm

You should be using the repo.
Also, wouldn't it be cooler if it supported both languages?

User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: fuzzy love

Post by TechnoCat » Sat Dec 04, 2010 9:44 pm

bartbes wrote:You should be using the repo.
Also, wouldn't it be cooler if it supported both languages?
Would that mean looking at the file extensions to figure out which language or adding a "#!/usr/bin..." type thing? Or is there an even better method I'm not thinking of?

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests