Boids
- alberto_lara
- Party member
- Posts: 372
- Joined: Wed Oct 30, 2013 8:59 pm
Re: Boids
Cool demo.
I have a couple of suggestions about the code:
The line above creates a lot of intermediate tables, you can just use 2 variables or do:
Another thing:
Could become:
The examples are untested, but should work as I've used these before.
I have a couple of suggestions about the code:
Code: Select all
closest = {x=boid.x,y=boid.y}
Code: Select all
closest.x, closest.y = boid.x, boid.y
Code: Select all
local angle_diff = target_angle - self.angle
if math.abs(angle_diff) > math.pi then
if angle_diff > 0 then
angle_diff = -(2*math.pi-target_angle+self.angle)
else
angle_diff = 2*math.pi-self.angle+target_angle
end
end
if angle_diff > 0 then
self.angle = self.angle + power*dt
else
self.angle = self.angle - power*dt
end
Code: Select all
local angle_diff = (self.angle - target_angle + math.pi)%(2*math.pi) - math.pi
if angle_diff ~= 0 then
local dir = angle_diff/math.abs(angle_diff)
self.angle = self.angle + dir*power*dt
end
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: Boids
I haven't looked at the code but it seems to get horrible performance on Android. Do you use spritebatches to render the triangles?
- alberto_lara
- Party member
- Posts: 372
- Joined: Wed Oct 30, 2013 8:59 pm
Re: Boids
He's calling love.graphics.polygon for each triangle so I guess this is equivalent to start and end the batch once per triangle, in Android. Maybe drawing all of them to a canvas would solve it?
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: Boids
Using a spritebatch would too. He just needs a triangle image.
- qubodup
- Inner party member
- Posts: 775
- Joined: Sat Jun 21, 2008 9:21 pm
- Location: Berlin, Germany
- Contact:
Re: Boids
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)
-- Don't force fullscreen (it frustrates those who want to try your game real quick) -- Develop for 1280x720 (so people can make HD videos)
- NightKawata
- Party member
- Posts: 294
- Joined: Tue Jan 01, 2013 9:18 pm
- Location: Cyberspace, Room 6502
- Contact:
Re: Boids
now the next step is for someone to create texture mods
i recommend ants
i would like to see ants swarming around
then the next step is to make an anthill background
duuuuuude ant simulator 2016 that's official as f*** yo
-------------------------------------------------
I like the music and really cannot stop being reminded of ants, though.
Would turn into a nice Ant Simulator or Cockroach Simulator; I mean seriously, who doesn't love anthills
i recommend ants
i would like to see ants swarming around
then the next step is to make an anthill background
duuuuuude ant simulator 2016 that's official as f*** yo
-------------------------------------------------
I like the music and really cannot stop being reminded of ants, though.
Would turn into a nice Ant Simulator or Cockroach Simulator; I mean seriously, who doesn't love anthills
"I view Python for game usage about the same as going fishing with a stick of dynamite. It will do the job but it's big, noisy, you'll probably get soaking wet and you've still got to get the damn fish out of the water." -taylor
- alberto_lara
- Party member
- Posts: 372
- Joined: Wed Oct 30, 2013 8:59 pm
Re: Boids
Or flying birds!then the next step is to make an anthill background
Who is online
Users browsing this forum: No registered users and 33 guests