Jump to content




Explosion Animation


  • You cannot reply to this topic
8 replies to this topic

#1 ReBraLaCC

  • Members
  • 100 posts
  • LocationSublime Text 2

Posted 28 May 2016 - 09:14 AM

I've been trying a lot with finding out a way of getting a randomized explosion on my terminal, but most of the times it doesnt seem to work.... Yes i've tried math.random but i still know what patterns it is going to make and i want them completely random... Maybe some CC master knows how to do this and would be able to help me with this problem...

- ReBraLa

#2 InDieTasten

  • Members
  • 357 posts
  • LocationGermany

Posted 28 May 2016 - 09:27 AM

2 scnenarios i can think of right now:
- your algorithm isn't utilizing the random input, by cancelling it out in some obscure way you don't see at first sight or making its effect on the outcome very small.
- the generator is giving you the same numbers all the time, because you are seeding it with the same number

for any concrete advice, we have to see your code. you essentially told us nothing, but that you are using math.random somewhere in your code.

Edited by InDieTasten, 28 May 2016 - 09:29 AM.


#3 ReBraLaCC

  • Members
  • 100 posts
  • LocationSublime Text 2

Posted 28 May 2016 - 10:06 AM

View PostInDieTasten, on 28 May 2016 - 09:27 AM, said:

for any concrete advice, we have to see your code. you essentially told us nothing, but that you are using math.random somewhere in your code.

local begin = "expframes/begin"
local secondframes = "expframes/secondframes"
local between = "expframes/between"
local en = "expframes/end"
beginframes = {"btex1","btex2","btex3"}
secondframes = {"scex1","scex1","scex1")
betweenframes = {"btex1","btex2","btex3"}
endframes = {"enex1","enex2","enex3"}
function explosion()
paintutils.drawImage(paintutils.loadImage(begin.."/"..beginframes[math.random(1,3)]),1,1)
paintutils.drawImage(paintutils.loadImage(second.."/"..secondframes[math.random(1,3)]),1,1)
paintutils.drawImage(paintutils.loadImage(between.."/"..betweenframes[math.random(1,3)]),1,1)
paintutils.drawImage(paintutils.loadImage(en.."/"..endframes[math.random(1,3)]),1,1)
end
explosion()


#4 Yevano

  • Members
  • 376 posts
  • LocationUSA

Posted 28 May 2016 - 11:47 AM

I can see a few possible problems. Your second frame is always the same, because all the entries in secondframes are "scex1". You're also drawing frames really fast (though this depends also on how large those images are). Try sleeping at least one tick between each animation frame. Other than that, maybe you should try generating your frames procedurally rather than picking them up from predefined textures. E.g., you could run a small particle simulation that you then render to the screen somehow.

#5 ReBraLaCC

  • Members
  • 100 posts
  • LocationSublime Text 2

Posted 28 May 2016 - 01:24 PM

local begin = "expframes/begin"
local secondframes = "expframes/secondframes"
local between = "expframes/between"
local en = "expframes/end"
beginframes = {"bex1","bex2","bex3"}
secondframes = {"scex1","scex2","scex3")
betweenframes = {"btex1","btex2","btex3"}
endframes = {"enex1","enex2","enex3"}
function explosion()
paintutils.drawImage(paintutils.loadImage(begin.."/"..beginframes[math.random(1,3)]),1,1)
sleep(0.05)
paintutils.drawImage(paintutils.loadImage(second.."/"..secondframes[math.random(1,3)]),1,1)
sleep(0.05)
paintutils.drawImage(paintutils.loadImage(between.."/"..betweenframes[math.random(1,3)]),1,1)
sleep(0.05)
paintutils.drawImage(paintutils.loadImage(en.."/"..endframes[math.random(1,3)]),1,1)
sleep(0.05)
end
explosion()

Changed the code a bit but I'm getting a weird error

bios.lua:14: [string "explosion"]:7: '}' expected

I don't know why I am getting this error because it is all correct what i seem to find, maybe i still have something wrong, let me know!

#6 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 28 May 2016 - 01:53 PM

The thing I don't get is how you've managed to keep the thing where you never define a "second" variable.

Anyway, you've got a ) where you meant to put a }.

#7 ReBraLaCC

  • Members
  • 100 posts
  • LocationSublime Text 2

Posted 28 May 2016 - 02:03 PM

View PostBomb Bloke, on 28 May 2016 - 01:53 PM, said:

Anyway, you've got a ) where you meant to put a }.

wow, i need glasses

View PostBomb Bloke, on 28 May 2016 - 01:53 PM, said:

The thing I don't get is how you've managed to keep the thing where you never define a "second" variable.

What do you mean second variable?

#8 InDieTasten

  • Members
  • 357 posts
  • LocationGermany

Posted 28 May 2016 - 05:37 PM

Also I think you should be loading all textures first, and then draw them one after the other instead of rendering one, load the next. render it. load the next. Just load all at once. then draw them on demand

#9 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 28 May 2016 - 07:17 PM

Line 2 reads as secondframes when it should read as second.





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users