Collaborative Coding Horror Experiment

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
Sheepolution
Party member
Posts: 264
Joined: Mon Mar 04, 2013 9:31 am
Location: The Netherlands
Contact:

Re: Collaborative Coding Horror Experiment

Post by Sheepolution »

Okay I guess you can see this as altering. Personally I don't see any problems with it. It doesn't make the code look any prettier you know :P.

I could also just have changed it to player.x, player.y = x, y. But that would be changing the whole thing. I had to find a clever way to change it.
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Collaborative Coding Horror Experiment

Post by davisdude »

I added enemies!
https://github.com/DaanHaaz/CCHE/pull/1

Edit:

Code: Select all

--Collaborative Coding Horror Experiment

function love.load()
	ScreenWidth = love.graphics.getWidth()
	ScreenHeight = love.graphics.getHeight()
   
   player = Player(100,100)
	
	Enemies = {}
	for _ = 1, love.math.random( 5, 10 ) do Enemies[#Enemies + 1] = NewEnemy( love.math.random( 32, ScreenWidth - 32 ), love.math.random( 32, ScreenHeight - 32 ) ) end
end


function love.update(dt)

   player:update(dt)
   for _, Enemy in ipairs( Enemies ) do Enemy:Update( dt ) end
end


function love.draw()
   local rumble = 10
   local c = healthcolor(player.health/player.health_max)
   love.graphics.setColor(c[1],c[2],c[3])
   local offset = {
      x=math.random(0,rumble),
      y=math.random(0,rumble)
   }
   local size = {
      w=love.window.getWidth()-offset.x-math.random(0,rumble),
      h=love.window.getHeight()-offset.y-math.random(0,rumble)
   }
   love.graphics.rectangle("fill",offset.x,offset.y,size.w,size.h)
   player.draw()
   
   for _, Enemy in ipairs( Enemies ) do Enemy:Draw( dt ) end
end

function love.keypressed(key)
   
end

function love.keyreleased(key)
   
end

function love.mousepressed(x,y,button)
   if button == "l" then
      player.x, player.y = player.setPlayerPosition(x, y)
   end
end

function love.mousereleased(x,y,button)
   
end

function Player(x,y)
   local self = {x=x,y=y}
   self.health = 100
   self.health_max = 100
   self.health_dt = 0
   self.health_dt_t = 0.1

   self.update = function(self,dt)
      self.health_dt = self.health_dt + dt
      if self.health_dt > self.health_dt_t then
         self.health_dt = self.health_dt - self.health_dt_t
         self:upkeep()
      end
      self:spin(dt)
   end
   self.upkeep = function(self)
     self.health = self.health - 1
   end
   function self.draw()
      love.graphics.push()
      love.graphics.translate(self.x, self.y)
      love.graphics.rotate(self.rotation)
      love.graphics.translate(-self.x, -self.y)

      love.graphics.setColor(30,80,120)
      love.graphics.circle("fill",self.x,self.y,50,50)
      love.graphics.setColor(255,255,255)
      love.graphics.circle("fill",self.x-25,self.y-15,5,50)
      love.graphics.circle("fill",self.x+25,self.y-15,5,50)
      love.graphics.arc("fill",self.x,self.y+10,20,-0,math.pi)

      love.graphics.pop()
   end

   self.rotation = 0
   function self.spin(self, dt)
      self.rotation = self.rotation + math.pi * 4 * dt
   end

   function self.setPlayerPosition(x,y)
      self.x, self.y = x, y
      return self.x, self.y
   end

   return self
end

function healthcolor(i)
   -- Clamp
   if i > 1 then i = 1 end
   if i < 0 then i = 0 end
   -- 0 -> 0.5: 255
   -- 0.5 -> 1: 255 .. 0
   local r = 255*2 - 255*2*i
   if r > 255 then r = 255 end
   -- 0 -> 0.5: 0 .. 255
   -- 0.5 -> 1: 255
   local g = 255*2*i
   if g > 255 then g = 255 end
   -- 0 -> 1: 0
   local b = 0
   return {r,g,b}
end

function NewEnemy( x, y )
	local Self = { x = x, y = y, Rotation = 0, Radius = love.math.random( 20, 50 ), Dir = 1 }
	Self.VelocityX = Self.Radius / 3
	
	Self.Rotation = 0
	function Self.Spin( Self, dt )
		Self.Rotation = Self.Rotation + math.pi * 4 * dt * Self.Dir
	end
	
	function Self.Update( Self, dt )
		Self.x = Self.x + Self.VelocityX 
		if Self.x - Self.Radius < 0 or Self.x + Self.Radius > ScreenWidth then Self.VelocityX, Self.Dir = Self.VelocityX * -1, Self.Dir * -1 end
		Self.Eyes = { 
			{ x = Self.x - ( Self.Radius / 2 ), y = Self.y - ( Self.Radius / 2 ), Radius = Self.Radius / 10 }, 
			{ x = Self.x + ( Self.Radius / 2 ), y = Self.y - ( Self.Radius / 2 ), Radius = Self.Radius / 10 }, 
		}
		Self:Spin( dt )
	end
	
	function Self.Draw( Self )
		love.graphics.push()
			love.graphics.translate( Self.x, Self.y )
			love.graphics.rotate( Self.Rotation )
			love.graphics.translate( -Self.x, -Self.y )
			
			love.graphics.setColor( 0, 0, 0 )
			love.graphics.circle( 'fill', Self.x, Self.y, Self.Radius )
			love.graphics.setColor( 255, 255, 255 )
			love.graphics.circle( 'fill', Self.Eyes[1].x, Self.Eyes[1].y, Self.Eyes[1].Radius )
			love.graphics.circle( 'fill', Self.Eyes[2].x, Self.Eyes[2].y, Self.Eyes[2].Radius )
			love.graphics.setColor( 255, 0, 0 )
			love.graphics.setLineWidth( Self.Radius / 16 )
			love.graphics.line( Self.Eyes[1].x - ( Self.Radius / 3 ), Self.Eyes[1].y - ( Self.Radius / 3 ), 
				Self.Eyes[1].x + Self.Radius / 2, Self.Eyes[1].y )
			love.graphics.line( Self.Eyes[2].x + ( Self.Radius / 3 ), Self.Eyes[2].y - ( Self.Radius / 3 ), 
				Self.Eyes[2].x - Self.Radius / 2, Self.Eyes[2].y )
			love.graphics.arc( 'fill', Self.x, Self.y + ( Self.Radius / 4 ), Self.Radius / 1.75, -0, math.pi )
		love.graphics.pop()
	end
	
	return Self
end
Last edited by davisdude on Mon Jun 09, 2014 9:06 pm, edited 1 time in total.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
WetDesertRock
Citizen
Posts: 67
Joined: Fri Mar 07, 2014 8:16 pm

Re: Collaborative Coding Horror Experiment

Post by WetDesertRock »

Perhaps a style guide is in order ;)

Maybe you could allow modification of changes if the intent and outcome can only be seen in the codebase? For instance, fixing that last commit to use agreed upon conventions.

Changing that player = Player(x,y) would also fit, as if you play the game you won't feel the difference.

Do you want to make a game that is crazy, or code in a crazy codebase?
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: Collaborative Coding Horror Experiment

Post by Ranguna259 »

WetDesertRock wrote:Do you want to make a game that is crazy, or code in a crazy codebase?
Why not both ?
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
User avatar
Sheepolution
Party member
Posts: 264
Joined: Mon Mar 04, 2013 9:31 am
Location: The Netherlands
Contact:

Re: Collaborative Coding Horror Experiment

Post by Sheepolution »

WetDesertRock wrote: Do you want to make a game that is crazy, or code in a crazy codebase?
Both.

What about this: Every commit you're allowed to comment 1 line.
You're allowed to commit after 2 other's commits.
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Collaborative Coding Horror Experiment

Post by davisdude »

I actually think having several different coding styles would quite contribute to the "Horror" of the experiment, which is why I intentionally did 4 space tabs (as I usually do) instead of the others. We are basing this of of something "Cthulhu Project : Let's Make Unmaintainable Code." ;)
Also, you should update the main post with the GitHub link.

Edit: Made a new commit. Is there a rule about double commiting? https://github.com/DaanHaaz/CCHE/pull/2
Gave teeth to enemies and made enemy movement speed slower.

Code: Select all

--Collaborative Coding Horror Experiment

function love.load()
	ScreenWidth = love.graphics.getWidth()
	ScreenHeight = love.graphics.getHeight()
   
   player = Player(100,100)
	
	Enemies = {}
	for _ = 1, love.math.random( 5, 10 ) do Enemies[#Enemies + 1] = NewEnemy( love.math.random( 50, ScreenWidth - 50 ), love.math.random( 50, ScreenHeight - 50 ) ) end
end


function love.update(dt)

   player:update(dt)
   for _, Enemy in pairs( Enemies ) do Enemy:Update( dt ) end
end


function love.draw()
   local rumble = 10
   local c = healthcolor(player.health/player.health_max)
   love.graphics.setColor(c[1],c[2],c[3])
   local offset = {
      x=math.random(0,rumble),
      y=math.random(0,rumble)
   }
   local size = {
      w=love.window.getWidth()-offset.x-math.random(0,rumble),
      h=love.window.getHeight()-offset.y-math.random(0,rumble)
   }
   love.graphics.rectangle("fill",offset.x,offset.y,size.w,size.h)
   player.draw()
   
   for _, Enemy in pairs( Enemies ) do Enemy:Draw( dt ) end
end

function love.keypressed(key)
   
end

function love.keyreleased(key)
   
end

function love.mousepressed(x,y,button)
   if button == "l" then
      player.x, player.y = player.setPlayerPosition(x, y)
   end
end

function love.mousereleased(x,y,button)
   
end

function Player(x,y)
   local self = {x=x,y=y}
   self.health = 100
   self.health_max = 100
   self.health_dt = 0
   self.health_dt_t = 0.1

   self.update = function(self,dt)
      self.health_dt = self.health_dt + dt
      if self.health_dt > self.health_dt_t then
         self.health_dt = self.health_dt - self.health_dt_t
         self:upkeep()
      end
      self:spin(dt)
	  self:CheckCircularCollisions( Enemies )
   end
   self.upkeep = function(self)
     self.health = self.health - 1
   end
   function self.draw()
      love.graphics.push()
      love.graphics.translate(self.x, self.y)
      love.graphics.rotate(self.rotation)
      love.graphics.translate(-self.x, -self.y)

      love.graphics.setColor(30,80,120)
      love.graphics.circle("fill",self.x,self.y,50,50)
      love.graphics.setColor(255,255,255)
      love.graphics.circle("fill",self.x-25,self.y-15,5,50)
      love.graphics.circle("fill",self.x+25,self.y-15,5,50)
      love.graphics.arc("fill",self.x,self.y+10,20,-0,math.pi)

      love.graphics.pop()
	  
	  love.graphics.setColor( 255, 255, 255 )
	  love.graphics.print( self.health )
   end

   self.rotation = 0
   function self.spin(self, dt)
      self.rotation = self.rotation + math.pi * 4 * dt
   end

   function self.setPlayerPosition(x,y)
      self.x, self.y = x, y
      return self.x, self.y
   end
   
	function self.CheckCircularCollisions( Self, CollisionTable )
		for _, Enemy in pairs( CollisionTable ) do
			local Length = GetDistance( Self.x, Self.y, Enemy.x, Enemy.y )
			if Length < 50 + Enemy.Radius then 
				Self.health = Self.health - Enemy.Damage 
				Enemy.Health = 0
			end
		end
	end

   return self
end

function GetDistance( x1, y1, x2, y2 )
	return math.sqrt( ( x1 - x2 ) ^ 2 + ( y1 - y2 ) ^ 2 )
end

function healthcolor(i)
   -- Clamp
   if i > 1 then i = 1 end
   if i < 0 then i = 0 end
   -- 0 -> 0.5: 255
   -- 0.5 -> 1: 255 .. 0
   local r = 255*2 - 255*2*i
   if r > 255 then r = 255 end
   -- 0 -> 0.5: 0 .. 255
   -- 0.5 -> 1: 255
   local g = 255*2*i
   if g > 255 then g = 255 end
   -- 0 -> 1: 0
   local b = 0
   return {r,g,b}
end

function NewEnemy( x, y )
	local Self = { x = x, y = y, Rotation = 0, Radius = love.math.random( 20, 50 ), Dir = 1, Index = #Enemies + 1 }
	Self.VelocityX = Self.Radius / 10
	Self.Damage = Self.Radius / 2
	Self.Health = Self.Radius * 5
	
	Self.Rotation = 0
	function Self.Spin( Self, dt )
		Self.Rotation = Self.Rotation + math.pi * ( Self.Radius / 20 ) * dt * Self.Dir
	end
	
	function Self.Update( Self, dt )
		if Self.Health <= 0 then Enemies[Self.Index] = nil return end
		Self.x = Self.x + Self.VelocityX 
		if Self.x - Self.Radius < 0 or Self.x + Self.Radius > ScreenWidth then Self.VelocityX, Self.Dir = Self.VelocityX * -1, Self.Dir * -1 end
		Self.Eyes = { 
			{ x = Self.x - ( Self.Radius / 2 ), y = Self.y - ( Self.Radius / 2 ), Radius = Self.Radius / 10 }, 
			{ x = Self.x + ( Self.Radius / 2 ), y = Self.y - ( Self.Radius / 2 ), Radius = Self.Radius / 10 }, 
		}
		Self:Spin( dt )
	end
	
	function Self.Draw( Self )
		love.graphics.push()
			love.graphics.translate( Self.x, Self.y )
			love.graphics.rotate( Self.Rotation )
			love.graphics.translate( -Self.x, -Self.y )
			
			-- Body
			love.graphics.setColor( 0, 0, 0 )
			love.graphics.circle( 'fill', Self.x, Self.y, Self.Radius )
			-- Eyes
			love.graphics.setColor( 255, 255, 255 )
			love.graphics.circle( 'fill', Self.Eyes[1].x, Self.Eyes[1].y, Self.Eyes[1].Radius )
			love.graphics.circle( 'fill', Self.Eyes[2].x, Self.Eyes[2].y, Self.Eyes[2].Radius )
			-- Mouth
			love.graphics.setColor( 255, 0, 0 )
			love.graphics.setLineWidth( Self.Radius / 16 )
			love.graphics.line( Self.Eyes[1].x - ( Self.Radius / 3 ), Self.Eyes[1].y - ( Self.Radius / 3 ), 
				Self.Eyes[1].x + Self.Radius / 2, Self.Eyes[1].y )
			love.graphics.line( Self.Eyes[2].x + ( Self.Radius / 3 ), Self.Eyes[2].y - ( Self.Radius / 3 ), 
				Self.Eyes[2].x - Self.Radius / 2, Self.Eyes[2].y )
			love.graphics.arc( 'fill', Self.x, Self.y + ( Self.Radius / 4 ), Self.Radius / 1.75, -0, math.pi )
			-- Teeth
			love.graphics.setColor( 255, 255, 255 )
			local MouthWidth = ( Self.Radius / 1.75 ) * 2
			local MouthStartX = Self.x - MouthWidth / 2
			local MouthY = Self.y + ( Self.Radius / 4 )
			local NumTeeth = Self.Radius
			local TeethSeperation = MouthWidth / NumTeeth
			local TeethHeight = MouthWidth / 6
			for Index = 0, NumTeeth - 1 do 
				local ToothX = MouthStartX + ( TeethSeperation * Index )
				love.graphics.polygon( 'fill', ToothX, MouthY, ToothX + ( TeethSeperation / 2 ), MouthY + TeethHeight, ToothX + TeethSeperation, MouthY )
			end
		love.graphics.pop()
	end
	
	return Self
end
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
Sheepolution
Party member
Posts: 264
Joined: Mon Mar 04, 2013 9:31 am
Location: The Netherlands
Contact:

Re: Collaborative Coding Horror Experiment

Post by Sheepolution »

As long as the edits aren't too big.

We can start making all these extra rules, but in the end people should just do what feels right and have fun with it. As long as people keep the updates small, modify or comment out only a few lines, I'm okay with it.
User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

Re: Collaborative Coding Horror Experiment

Post by Kingdaro »

Some of the suggestion you guys make almost completely defeats the purpose of the "experiment". The point is to try to keep the code maintainable but it just ends up becoming a clusterfuck anyway. Intentionally making the code look bad is stupid. For the game to be truly seen through, the no-modification rule must accept absolutely no exceptions (aside from editing constants), even when the functionality of the modification remains the same.

EDIT: Also, the commenting rule can be circumvented as such, before:

Code: Select all

print 'Hello there!'
After (tabbing counts as adding to a line):

Code: Select all

if false then
   print 'Hello there!'
end
And a bunch of other random tricks, such as wrapping it in an unused function. Because of this, limiting comments per commit is basically pointless.
User avatar
OttoRobba
Party member
Posts: 104
Joined: Mon Jan 06, 2014 5:02 am
Location: Sao Paulo, Brazil

Re: Collaborative Coding Horror Experiment

Post by OttoRobba »

And if someone really wants to troll, adding a --[[ to the first line of code alters the contents but not the lines :P
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Collaborative Coding Horror Experiment

Post by davisdude »

Been a while, so I though I'd revive it!
Pull Request

Code: Select all

--Collaborative Coding Horror Experiment

function love.load()
	ScreenWidth = love.graphics.getWidth()
	ScreenHeight = love.graphics.getHeight()
   
   player = Player(100,100)
	
	Enemies = {}
	for _ = 1, love.math.random( 5, 10 ) do Enemies[#Enemies + 1] = NewEnemy( love.math.random( 50, ScreenWidth - 50 ), love.math.random( 50, ScreenHeight - 50 ) ) end
end


function love.update(dt)

   player:update(dt)
   for _, Enemy in pairs( Enemies ) do Enemy:Update( dt ) end
end


function love.draw()
   local rumble = 10
   local c = healthcolor(player.health/player.health_max)
   love.graphics.setColor(c[1],c[2],c[3])
   local offset = {
      x=math.random(0,rumble),
      y=math.random(0,rumble)
   }
   local size = {
      w=love.window.getWidth()-offset.x-math.random(0,rumble),
      h=love.window.getHeight()-offset.y-math.random(0,rumble)
   }
   love.graphics.rectangle("fill",offset.x,offset.y,size.w,size.h)
   player.draw()
   
   for _, Enemy in pairs( Enemies ) do Enemy:Draw( dt ) end
end

function love.keypressed(key)
   
end

function love.keyreleased(key)
   
end

function love.mousepressed(x,y,button)
   if button == "l" then
      player.x, player.y = player.setPlayerPosition(x, y)
   end
end

function love.mousereleased(x,y,button)
	
end

function Player(x,y)
   local self = {x=x,y=y}
   self.health = 100
   self.health_max = 100
   self.health_dt = 0
   self.health_dt_t = 0.1
   self.radius = 50
   self.speed = 256
   self.direction = 1

   self.update = function(self,dt)
      self.health_dt = self.health_dt + dt
      if self.health_dt > self.health_dt_t then
         self.health_dt = self.health_dt - self.health_dt_t
         self:upkeep()
      end
      self:spin(dt)
	  self:CheckCircularCollisions( Enemies )
	  
		if love.keyboard.isDown( 'w' ) then self.y = self.y - self.speed * dt end
		if love.keyboard.isDown( 'a' ) then self.x, self.direction = self.x - self.speed * dt, -1 end
		if love.keyboard.isDown( 's' ) then self.y = self.y + self.speed * dt end
		if love.keyboard.isDown( 'd' ) then self.x, self.direction = self.x + self.speed * dt, 1 end
		if not love.keyboard.isDown( 'a' ) and not love.keyboard.isDown( 'd' ) then self.direction = 0 end
		
		if love.keyboard.isDown( 'up' ) then self.radius = ( self.radius + 1 ) < 75 and self.radius + 1 or 75 end
		if love.keyboard.isDown( 'down' ) then self.radius = ( self.radius - 1 ) > 20 and self.radius - 1 or 20 end
   end
   self.upkeep = function(self)
     self.health = self.health - 1
   end
   function self.draw()
      love.graphics.push()
      love.graphics.translate(self.x, self.y)
      love.graphics.rotate(self.rotation)
      love.graphics.translate(-self.x, -self.y)

      love.graphics.setColor(30,80,120)
      love.graphics.circle("fill",self.x,self.y,self.radius,self.radius)
      love.graphics.setColor(255,255,255)
      love.graphics.circle("fill",self.x-self.radius / 2,self.y - ( self.radius / ( 10 / 3 ) ),self.radius / 10,self.radius)
      love.graphics.circle("fill",self.x+self.radius / 2,self.y - ( self.radius / ( 10 / 3 ) ),self.radius / 10,self.radius)
      love.graphics.arc("fill",self.x,self.y+(self.radius/5),self.radius/2.5,-0,math.pi)

      love.graphics.pop()
	  
	  love.graphics.setColor( 255, 255, 255 )
	  love.graphics.print( self.health )
   end

   self.rotation = 0
   function self.spin(self, dt)
      self.rotation = self.rotation + ( math.pi * 4 * dt * self.direction )
   end

   function self.setPlayerPosition(x,y)
      self.x, self.y = x, y
      return self.x, self.y
   end
   
	function self.CheckCircularCollisions( Self, CollisionTable )
		for _, Enemy in pairs( CollisionTable ) do
			local Length = GetDistance( Self.x, Self.y, Enemy.x, Enemy.y )
			if Length < self.radius + Enemy.Radius then 
				Self.health = Self.health - Enemy.Damage 
				Enemy.Health = 0
			end
		end
	end

   return self
end

function GetDistance( x1, y1, x2, y2 )
	return math.sqrt( ( x1 - x2 ) ^ 2 + ( y1 - y2 ) ^ 2 )
end

function healthcolor(i)
   -- Clamp
   if i > 1 then i = 1 end
   if i < 0 then i = 0 end
   -- 0 -> 0.5: 255
   -- 0.5 -> 1: 255 .. 0
   local r = 255*2 - 255*2*i
   if r > 255 then r = 255 end
   -- 0 -> 0.5: 0 .. 255
   -- 0.5 -> 1: 255
   local g = 255*2*i
   if g > 255 then g = 255 end
   -- 0 -> 1: 0
   local b = 0
   return {r,g,b}
end

function NewEnemy( x, y )
	local Self = { x = x, y = y, Rotation = 0, Radius = love.math.random( 20, 50 ), Dir = 1, Index = #Enemies + 1 }
	Self.VelocityX = Self.Radius / 10
	Self.Damage = Self.Radius / 2
	Self.Health = Self.Radius * 5
	
	Self.Rotation = 0
	function Self.Spin( Self, dt )
		Self.Rotation = Self.Rotation + math.pi * ( Self.Radius / 20 ) * dt * Self.Dir
	end
	
	function Self.Update( Self, dt )
		if Self.Health <= 0 then Enemies[Self.Index] = nil return end
		Self.x = Self.x + Self.VelocityX 
		if Self.x - Self.Radius < 0 or Self.x + Self.Radius > ScreenWidth then Self.VelocityX, Self.Dir = Self.VelocityX * -1, Self.Dir * -1 end
		Self.Eyes = { 
			{ x = Self.x - ( Self.Radius / 2 ), y = Self.y - ( Self.Radius / 2 ), Radius = Self.Radius / 10 }, 
			{ x = Self.x + ( Self.Radius / 2 ), y = Self.y - ( Self.Radius / 2 ), Radius = Self.Radius / 10 }, 
		}
		Self:Spin( dt )
	end
	
	function Self.Draw( Self )
		love.graphics.push()
			love.graphics.translate( Self.x, Self.y )
			love.graphics.rotate( Self.Rotation )
			love.graphics.translate( -Self.x, -Self.y )
			
			-- Body
			love.graphics.setColor( 0, 0, 0 )
			love.graphics.circle( 'fill', Self.x, Self.y, Self.Radius )
			-- Eyes
			love.graphics.setColor( 255, 255, 255 )
			love.graphics.circle( 'fill', Self.Eyes[1].x, Self.Eyes[1].y, Self.Eyes[1].Radius )
			love.graphics.circle( 'fill', Self.Eyes[2].x, Self.Eyes[2].y, Self.Eyes[2].Radius )
			-- Mouth
			love.graphics.setColor( 255, 0, 0 )
			love.graphics.setLineWidth( Self.Radius / 16 )
			love.graphics.line( Self.Eyes[1].x - ( Self.Radius / 3 ), Self.Eyes[1].y - ( Self.Radius / 3 ), 
				Self.Eyes[1].x + Self.Radius / 2, Self.Eyes[1].y )
			love.graphics.line( Self.Eyes[2].x + ( Self.Radius / 3 ), Self.Eyes[2].y - ( Self.Radius / 3 ), 
				Self.Eyes[2].x - Self.Radius / 2, Self.Eyes[2].y )
			love.graphics.arc( 'fill', Self.x, Self.y + ( Self.Radius / 4 ), Self.Radius / 1.75, -0, math.pi )
			-- Teeth
			love.graphics.setColor( 255, 255, 255 )
			local MouthWidth = ( Self.Radius / 1.75 ) * 2
			local MouthStartX = Self.x - MouthWidth / 2
			local MouthY = Self.y + ( Self.Radius / 4 )
			local NumTeeth = Self.Radius
			local TeethSeperation = MouthWidth / NumTeeth
			local TeethHeight = MouthWidth / 6
			for Index = 0, NumTeeth - 1 do 
				local ToothX = MouthStartX + ( TeethSeperation * Index )
				love.graphics.polygon( 'fill', ToothX, MouthY, ToothX + ( TeethSeperation / 2 ), MouthY + TeethHeight, ToothX + TeethSeperation, MouthY )
			end
		love.graphics.pop()
	end
	
	return Self
end
Added keyboard movement: use wasd to move, up to increase size, down to decrease size. You can still click if you want.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
Post Reply

Who is online

Users browsing this forum: aikusuuta, Bing [Bot] and 11 guests