I saw a good example of this somewhere, but I seem to have lost it. I'm referring to animations where the shape itself is distorted, rather than just rotating, scaling, or translating distinct parts. It's more or less essential for making organic characters that actually look good without making gigantic spritesheets at a limited framerate. Especially for mobile devices, where space is limited but GPU power usually isn't (in recent devices, anyway.)spectralcanine wrote:About skeletal animations, how are triangles (or texture coordinates) related?
New guy, performance question
Re: New guy, performance question
-
- Citizen
- Posts: 65
- Joined: Sat Dec 22, 2012 8:17 am
Re: New guy, performance question
Ah yes, weights (multiple bones affecting the same geometry). Not really sure how applicable they are for 2D games, but I guess that mostly depends on the artist.Kyle wrote:I saw a good example of this somewhere, but I seem to have lost it. I'm referring to animations where the shape itself is distorted, rather than just rotating, scaling, or translating distinct parts. It's more or less essential for making organic characters that actually look good without making gigantic spritesheets at a limited framerate. Especially for mobile devices, where space is limited but GPU power usually isn't (in recent devices, anyway.)spectralcanine wrote:About skeletal animations, how are triangles (or texture coordinates) related?
Do note that you'd need to make actual geometries, with good topology, for this to look anything near decent (as in, a few boxes would look ridiculously bad). Easiest way would be to use an existing 3D application and just not use depth (or ignore it when importing the model, or better - use it for character layers).
The actual skinning would benefit much from vertex shaders (Love 0.9.0?), but I guess it doesn't really matter unless you have tens of thousands of vertices.
Re: New guy, performance question
That's the point. You can't really do it without texture coordinates on your vertices. Vertex shaders would be the best way to do it, I don't think calculating all that in slooooow Lua would be good for much more than a few hundred vertices, and that almost defeats the point.spectralcanine wrote:Ah yes, weights (multiple bones affecting the same geometry). Not really sure how applicable they are for 2D games, but I guess that mostly depends on the artist.Kyle wrote:I saw a good example of this somewhere, but I seem to have lost it. I'm referring to animations where the shape itself is distorted, rather than just rotating, scaling, or translating distinct parts. It's more or less essential for making organic characters that actually look good without making gigantic spritesheets at a limited framerate. Especially for mobile devices, where space is limited but GPU power usually isn't (in recent devices, anyway.)spectralcanine wrote:About skeletal animations, how are triangles (or texture coordinates) related?
Do note that you'd need to make actual geometries, with good topology, for this to look anything near decent (as in, a few boxes would look ridiculously bad). Easiest way would be to use an existing 3D application and just not use depth (or ignore it when importing the model, or better - use it for character layers).
The actual skinning would benefit much from vertex shaders (Love 0.9.0?), but I guess it doesn't really matter unless you have tens of thousands of vertices.
Re: New guy, performance question
Thanks for all the tips and explanations guys
(And the tech talk, which is probably also pretty cool but so far goes a bit over my head )
To have a bit of a test-run with LÖVE I made Missile Cömmand. If anyone would be willing to do a short code-review I'd love to hear what I messed up and could've done easier/better
I think I'll be working with this framework more in the future, because so far I'm really liking it!
(And the tech talk, which is probably also pretty cool but so far goes a bit over my head )
To have a bit of a test-run with LÖVE I made Missile Cömmand. If anyone would be willing to do a short code-review I'd love to hear what I messed up and could've done easier/better
I think I'll be working with this framework more in the future, because so far I'm really liking it!
- Attachments
-
- missilecömmand.love
- The game
- (24.3 KiB) Downloaded 693 times
- Hexenhammer
- Party member
- Posts: 175
- Joined: Sun Feb 17, 2013 8:19 am
Re: New guy, performance question
Looks nice, except that you should use locals instead of globals e.g.:
instead of..
Globals are both, less efficient (access is slower) and more error-prone. Personally I think you should almost never use globals.
Code: Select all
local blasts = {}
function love.update( dt )
...
for key, value in ipairs( blasts ) do
...
end
Code: Select all
function love.load()
...
blasts = {}
...
end
function love.update( dt )
...
for key, value in ipairs( blasts ) do
...
end
Re: New guy, performance question
What will be the scope if I define it as local just before love.update?
Will it be available in all the love. functions? (Since I need to draw them?)
Will it be available in deeper functions?
Using locals is probably a better idea but I was afraid they'd go out of scope in the draw event.
Will it be available in all the love. functions? (Since I need to draw them?)
Will it be available in deeper functions?
Using locals is probably a better idea but I was afraid they'd go out of scope in the draw event.
Re: New guy, performance question
Defining it as local at the top level of your file will make it local to THAT file. It'll carry down into scopes inside that - for example, this will work as expected:
However, worrying about this is micro-optimization and that's bad. Unless you're accessing something thousands or millions of times, it's not going to be much of a problem. The difference could probably be measured in microseconds.
Code: Select all
local x = 42
function love.update(dt)
if x == 42 then
print("this will print!")
end
end
- Hexenhammer
- Party member
- Posts: 175
- Joined: Sun Feb 17, 2013 8:19 am
Re: New guy, performance question
The variable will be accessible in all code following its original declaration.Plu wrote:What will be the scope if I define it as local just before love.update?
It will be available in all functions (love. or your own) which follow its declaration.Will it be available in all the love. functions? (Since I need to draw them?)
Yes, nesting is irrelevant here.Will it be available in deeper functions?
You can make a file scope local (i.e. it will be available to all functions in that file) by simply putting your local declarations at the top of the file e.g.Using locals is probably a better idea but I was afraid they'd go out of scope in the draw event.
Code: Select all
local blasts = {}
-- Everything after the above line can access "blasts", no matter how deeply nested or whatever
Code: Select all
local Area = {
width = 128
height = 128
Clear = function()
..
end
}
Code: Select all
return Area
Code: Select all
local Area = require "Area" -- this assumes your Area module is in a file named "Area.lua"
Code: Select all
Area.Clear()
for i = 1, Area.width do
..
In general you want to modularize your project if it is meant to be big instead of stuffing everything into main.lua. It's not necessary but after your code reaches a certain size you start to appreciate some organization.
- Hexenhammer
- Party member
- Posts: 175
- Joined: Sun Feb 17, 2013 8:19 am
Re: New guy, performance question
No, it's not. The big issue here is not the overhead caused by accessing globals. But that code written like that is extremely error-prone, hard to read, and maintain.Kyle wrote: However, worrying about this is micro-optimization
- josefnpat
- Inner party member
- Posts: 955
- Joined: Wed Oct 05, 2011 1:36 am
- Location: your basement
- Contact:
Re: New guy, performance question
Very nice game. I didn't look at the source code, but I did enjoy the gameplay;
Did you mean for some of the missiles to go off screen and miss the cities entirely?
Also, consider speeding the missiles up, and making the explosions larger :)
Did you mean for some of the missiles to go off screen and miss the cities entirely?
Also, consider speeding the missiles up, and making the explosions larger :)
Missing Sentinel Software | Twitter
FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
Who is online
Users browsing this forum: No registered users and 1 guest