TechnoCat wrote:
My brother used to get people to run that at lan parties. He claimed, "It will speed up your computer."
The Unix equivalent these days with OS X and Linux is
Which deletes all files and folders in the root of the HD. But only if you enter your password as a safety. Sudo allows it to ask for the password. Without the sudo it would fail as it doesn't have permission to delete all those files. The real question, does any poor soul ever fall for these jokes?
On topic:
The animation system I created for my main menu works soooo nicely. I want to show it to you in motion. But my screen recorder cuts the framerate of the video so low you wouldn't even see the smooth animation. Sad to think my digital camera's built-in video recording would record a higher framerate... SEE BELOW:
http://www.youtube.com/watch?v=-nQ8SnW1B9s
I built an animation system based on Tables. It's rudimentary and depends on all animatable variables being defined at start or specifically knowing the ID of the specific animation. Right now I only use them on menu items. Like the logo, the words for each menu option. This isn't meant for game use yet. Just for menu animating. And I think it works really well.
At Load you specify each animated object. Their ID and where they start and their Name. (A string of text I use for their menu name to make things simple since I switched to a font based menu system instead of specific images.)
Any time you call the
moveAnimationTo() function you tell it which animation to move, where you want it to move to and how many frames to move in. (I would switch to a time based system but it's not precise enough and things would be off. This works for now.)
On the first frame of the animation the game calculates how many pixels there should be between each step both horizontally and vertically. Then the animation takes over and moves the object the correct amount of pixels. When it reaches its destination it is deactivated waiting for the next move time.
The animation functions don't move the object, rather just the variables. So if I want to draw a picture that is animating, I simply replace its x and y with the
animations[id].cx and
animations[id].cy variables because the animations are being called at all times in the menu.
So basically when the game starts, the title is off the top of the screen and the menu options are all off the bottom. When the menu is loaded, they are told to move to their correct spots on the screen. When you go to the Load screen or the Options screen they are moved off while others are moved on. It is all nice and smooth. As you will see in the video.
Future plans include other animations like color changing and scaling values that can also be referenced. These are just simple point A to point B animations. I don't know if I can do callbacks where a specific function is called when the animation stops else I'd do more with it.
Code: Select all
--ANIMATING
animations = {}
function createAnimation(id, name, startX, startY)
table.insert(animations, id, {sx = startX, sy = startY, ex = startX, ey = startY, cx = -1, cy = 0, steps = 0, curStep = 0, done = true, xms = 0, yms = 0, name = name, name2 = ""})
end
function moveAnimations()
for i, a in ipairs(animations) do
if a.curStep == 0 then
a.cx = a.sx
a.cy = a.sy
if a.ex > a.sx then a.xms = (a.ex - a.sx) / a.steps elseif a.sx > a.ex then a.xms = -(a.sx - a.ex) / a.steps else a.xms = 0 end
if a.ey > a.sy then a.yms = (a.ey - a.sy) / a.steps elseif a.sy > a.ey then a.yms = -(a.sy - a.ey) / a.steps else a.yms = 0 end
end
if a.curStep < a.steps then a.curStep = a.curStep + 1 end
if a.done == false then
a.cx = a.cx + a.xms
a.cy = a.cy + a.yms
end
if a.curStep == a.steps then
a.done = true
a.sx = a.ex
a.sy = a.ey
end
end
end
function moveAnimationTo(id, nx, ny, s)
animations[id].ex = nx
animations[id].ey = ny
animations[id].steps = s
animations[id].curStep = 0
animations[id].done = false
end
Make sure to call the Create functions at
load(), and call the
moveAnimations() function in
update(). Then whenever you wish to move one, simply call
moveAnimationTo() with the appropriate values.