FX Help! And code!

Do you guy’s have sum special FX code?

(explosions,fire)

Do you have any coding experience? I think maybe you need to start with the basics and work up instead of just asking people to do everything for you.

you can get yourself explosion animation frames with e.g. http://www.positech.co.uk/content/explosion/explosiongenerator.html
or

http://www.blitzbasic.com/Community/posts.php?topic=30117

or a few more here

http://hasgraphics.com/tag/explosion/

you have to extract these images by yourself though…

WoW cool… :slight_smile:

But do you have sum animation code. [-O<

A text mod (hack)

(you need a ipad to see it) :slight_smile:

½
¼
¾
?


|
?
\
[
]
{
}



·

?
?
?
?
?
?
?
¡
¿
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
ß
Á
À
Ã
Ã…
Ã¥
Ä
ä
Æ
æ
Ç
ç
É
é
È
è
Ê
ê
Ë
ë
Í
í
Ì
ì
ÃŽ
î
Ñ
ñ
Ó
ó
Ã’
ò
Ô
ô
Ö
ö
Ø
ø
Ú
ú
Ù
ù
Ü
ü
Ž
ž
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
¤
°
©
®





¿
¡
œ
?
´
?
?
?
¨
ˆ
ø
?
Ã¥
ß
?
ƒ
©

¬
?
æ
°
«
»

Cool :-bd

Very good sources! I would have never imagined… Thanks, @Inviso.

Do you guy’s have sum code for animation [-O<

Yes I do!

And I’m make-ing a 2d side-scroller game. :wink:

And can you tell me haw to post movie [-O<

Upload to YouTube, copy /paste the link to the video here, done :slight_smile:

I will do that tomorrow :smiley:

MY Code (not the game)

--by connorbot999:)
function setup()
    smooth()
    iparameter("frameDelay", 1, 25, 10)
    animation = Animation({("Small World:Heart"),
                         ("Small World:Heart Gold"),
                          },
                            10)
end

function draw()
    background(0, 0, 0, 255)
    animation:setFrameDelay(frameDelay)
    animation:draw(WIDTH / 2, HEIGHT / 2) 
end

Animation = class()
function Animation:init(frames, delay)
    self.frames = frames 
    self.currentFrame = 1 
    self.frameDelay = delay 
    self.count = 1 
end
function Animation:draw(x, y)
    self.count = self.count + 1
    if self.count > self.frameDelay then
        self.count = 1
        self.currentFrame = self.currentFrame + 1
        if self.currentFrame > table.maxn(self.frames) then
            self.currentFrame = 1
        end
    end
    sprite(self.frames[self.currentFrame], x, y,200) 
end

function Animation:setFrameDelay(newDelay)
    self.frameDelay = newDelay
end

Is my best code :smiley:

Not bad frame animation, @Connerbot999. I wanted to let you know that the sprite() function is a little slow, and can bog down when you have a lot of sprites going at the same time. Mesh is much faster for animation. I rewrote your code to switch to mesh. If you get a lot of meshes of animations going at once, you will be happy you switched to meshes.

function setup()
    smooth()
    iparameter("frameDelay", 1, 25, 10)
    animation = Animation({"Small World:Heart",
                         "Small World:Heart Gold",
                          },
                            10, WIDTH/2, HEIGHT/2, 5)
end

function draw()
    background(0, 0, 0, 255)
    animation:setFrameDelay(frameDelay)
    animation:draw() 
end

Animation = class()
function Animation:init(frames,delay,x,y,size)
    self.x = x
    self.y = y
    self.frames = frames 
    self.currentFrame = 1 
    self.frameDelay = delay 
    self.count = 1 
    self.mesh = mesh()
    self.mesh.texture = self.frames[self.currentFrame]
    local w,h = spriteSize(self.frames[self.currentFrame])
    self.mesh:addRect(x,y,w*size,h*size)
end
function Animation:draw()
    self.count = self.count + 1
    if self.count > self.frameDelay then
        self.count = 1
        self.currentFrame = self.currentFrame + 1
        if self.currentFrame > table.maxn(self.frames) then
            self.currentFrame = 1
        end
        self.mesh.texture = self.frames[self.currentFrame]
    end
    self.mesh:draw()
end

function Animation:setFrameDelay(newDelay)
    self.frameDelay = newDelay
end

Hope that helps.

@Vega Even faster (I think) would be to draw all frames to a single image, use that as the mesh texture, and just update the texRect of the animation rect on each new frame to display the correct part of the image. This would prevent you having to switch out the texture of the mesh each frame :slight_smile:

I think, @frosty, that you are probably right, that would be faster. Right now, it is basically reading the image from disk every time it changes frame. (Codea may be smart enough to keep the images in memory, I’m not sure.) In any case, your method would ensure that the images were accessed from the storage only once, then accessed from memory on successive calls. That would be better.