;###################################################
;##### Particles by SumWon #####
;#### Thanks for trying out my particle engine! ####
;### To open it, right click and goto ###
;#### SumWon's stuff>Particle Engine or ####
;##### type /pe.startup #####
;###################################################
on *:LOAD:timer 1 1 $input(Thanks for installing my particle engine! To open it $+ $chr(44) right click and goto SumWon's Creations>Particle Engine or type /pe.startup,o,Welcome,)
menu status,channel {
SumWon's Creations
.Paricle Engine:{
pe.startup
}
}
menu @pe {
sclick:{
if ($inrect($mouse.x,$mouse.y,305,0,15,15)) {
.timerpe off
close -@ @pe
}
;# Syntax for createParticle command: createparticle color size x y angle speed life gravity [picture]
if ($mouse.y < 200) {
if (%pe.intro) unset %pe.intro
var %i = %pe.amount
if (%pe.parttype == 1) {
while (%i) {
if (%pe.break) {
unset %pe.break
echo breaking
break
}
createparticle $rgb(%pe.red,%pe.green,%pe.blue) %pe.size $calc($mouse.x - %pe.size / 2) $calc($mouse.y - %pe.size / 2) $r(0,360) $r(%pe.mxspeed,%pe.mnspeed) %pe.life %pe.gravity
dec %i
}
}
}
else {
if ($mouse.y > 212 && $mouse.y < 223 && $mouse.x > $calc(60 + ( %pe.red / 2.55) - 2) && $mouse.x < $calc(60 + ( %pe.red / 2.55) + 6)) {
%pe.redsel = 1
}
else if ($mouse.y > 227 && $mouse.y < 238 && $mouse.x > $calc(60 + ( %pe.green / 2.55) - 2) && $mouse.x < $calc(60 + ( %pe.green / 2.55) + 6)) {
%pe.greensel = 1
}
else if ($mouse.y > 242 && $mouse.y < 253 && $mouse.x > $calc(60 + ( %pe.blue / 2.55) - 2) && $mouse.x < $calc(60 + ( %pe.blue / 2.55) + 6)) {
%pe.bluesel = 1
}
else if ($mouse.y > 257 && $mouse.y < 268 && $mouse.x > $calc(60 + %pe.mnspeed - 2) && $mouse.x < $calc(60 + %pe.mnspeed + 6)) {
%pe.mnspeedsel = 1
}
else if ($mouse.y > 272 && $mouse.y < 283 && $mouse.x > $calc(60 + %pe.mxspeed - 2) && $mouse.x < $calc(60 + %pe.mxspeed + 6)) {
%pe.mxspeedsel = 1
}
else if (%pe.parttype == 1 && $mouse.y > 287 && $mouse.y < 298 && $mouse.x > $calc(60 + %pe.amount - 2) && $mouse.x < $calc(60 + %pe.amount + 6)) {
%pe.amountsel = 1
}
else if (%pe.parttype == 2 && $mouse.y > 287 && $mouse.y < 298 && $mouse.x > $calc(60 + %pe.amount * 10 - 2) && $mouse.x < $calc(60 + %pe.amount * 10 + 6)) {
%pe.amountsel = 1
}
else if ($mouse.y > 302 && $mouse.y < 313 && $mouse.x > $calc(60 + %pe.size - 2) && $mouse.x < $calc(60 + %pe.size + 6)) {
%pe.sizesel = 1
}
else if ($mouse.y > 302 && $mouse.y < 313 && $mouse.x > $calc(238 + %pe.nozzle - 2) && $mouse.x < $calc(238 + %pe.nozzle + 6)) {
%pe.nozzlesel = 1
}
else if ($mouse.y > 214 && $mouse.y < 224 && $mouse.x > 225 && $mouse.x < 234) {
%pe.parttype = 1
%pe.amount = $round($calc(%pe.amount * 10),0)
}
else if ($mouse.y > 229 && $mouse.y < 238 && $mouse.x > 225 && $mouse.x < 234) {
%pe.parttype = 2
%pe.amount = $round($calc(%pe.amount / 10),0)
}
else if ($mouse.y > $calc(254 + %pe.gravity * 25 - 2) && $mouse.y < $calc(254 + %pe.gravity * 25 + 6) && $mouse.x > 185 && $mouse.x < 197) {
%pe.gravitysel = 1
}
else if ($mouse.y > 240 && $mouse.y < 300 && $mouse.x > 235 && $mouse.x < 295) {
%pe.anglesel = 1
}
}
}
mouse:{
if (%pe.redsel) {
%pe.red = $calc(($mouse.x - 60)*2.55)
if (%pe.red < 0) %pe.red = 0
if (%pe.red > 254) %pe.red = 254
}
else if (%pe.greensel) {
%pe.green = $calc(($mouse.x - 60)*2.55)
if (%pe.green < 0) %pe.green = 0
if (%pe.green > 254) %pe.green = 254
}
else if (%pe.bluesel) {
%pe.blue = $calc(($mouse.x - 60)*2.55)
if (%pe.blue < 0) %pe.blue = 0
if (%pe.blue > 254) %pe.blue = 254
}
else if (%pe.mnspeedsel) {
%pe.mnspeed = $calc(($mouse.x - 60))
if (%pe.mnspeed < 0) %pe.mnspeed = 0
if (%pe.mnspeed > 100) %pe.mnspeed = 100
if (%pe.mxspeed < %pe.mnspeed) %pe.mxspeed = %pe.mnspeed
}
else if (%pe.mxspeedsel) {
%pe.mxspeed = $calc(($mouse.x - 60))
if (%pe.mxspeed < 0) %pe.mxspeed = 0
if (%pe.mxspeed > 100) %pe.mxspeed = 100
if (%pe.mnspeed > %pe.mxspeed) %pe.mnspeed = %pe.mxspeed
}
else if (%pe.amountsel) {
if (%pe.parttype == 1) {
%pe.amount = $calc(($mouse.x - 60))
if (%pe.amount < 1) %pe.amount = 1
if (%pe.amount > 100) %pe.amount = 100
}
if (%pe.parttype == 2) {
%pe.amount = $calc(($mouse.x - 60) / 10)
if (%pe.amount < 1) %pe.amount = 1
if (%pe.amount > 10) %pe.amount = 10
}
%pe.amount = $round(%pe.amount,0)
}
else if (%pe.sizesel) {
%pe.size = $calc(($mouse.x - 60))
if (%pe.size < 2) %pe.size = 2
if (%pe.size > 100) %pe.size = 100
}
else if (%pe.nozzlesel) {
%pe.nozzle = $calc(($mouse.x - 238))
if (%pe.nozzle < 0) %pe.nozzle = 0
if (%pe.nozzle > 50) %pe.nozzle = 50
}
else if (%pe.gravitysel) {
%pe.gravity = $calc(($mouse.y - 254) / 25)
if (%pe.gravity < -1) %pe.gravity = -1
if (%pe.gravity > 1) %pe.gravity = 1
}
else if (%pe.anglesel) {
%pe.angle = $calc($pe.getangle(265,270,$mouse.x,$mouse.y) * -1)
}
}
leave:{
$pe.unsetmenubtns
}
uclick:{
$pe.unsetmenubtns
}
}
alias pe.unsetmenubtns {
unset %pe.redsel
unset %pe.greensel
unset %pe.bluesel
unset %pe.mxspeedsel
unset %pe.mnspeedsel
unset %pe.amountsel
unset %pe.sizesel
unset %pe.gravitysel
unset %pe.anglesel
unset %pe.nozzlesel
}
alias createparticle {
if (!$hget(particles)) hmake particles 100
var %x = 1
while ($hget(particles,$+(color.,%x))) {
;echo . $hget(particles,$+(color.,%x)) %x
inc %x
}
if (%x < 100) {
hadd particles $+(color.,%x) $1
hadd particles $+(size.,%x) $2
hadd particles $+(x.,%x) $3
hadd particles $+(y.,%x) $4
hadd particles $+(xs.,%x) $calc(0 + ($6 * $cos($5).deg))
hadd particles $+(ys.,%x) $calc(0 + ($6 * $sin($5).deg))
hadd particles $+(life.,%x) $7
hadd particles $+(grav.,%x) $8
hadd particles $+(pic.,%x) $9
}
;else %pe.break = 1
}
alias pe.startup {
if ($hget(particles)) hfree particles
if ($window(@pe)) close -@ @pe
%pe.red = 254
%pe.blue = 254
%pe.green = 254
%pe.mnspeed = 2
%pe.mxspeed = 7
%pe.life = 50
%pe.size = 3
%pe.gravity = 0.25
%pe.amount = 20
%pe.parttype = 1
%pe.angle = 90
%pe.nozzle = 0
%pe.intro = 1
window -paoCzdk0 +tndL @pe -1 -1 320 320
pe.loop
}
alias pe.loop {
clear -n @pe
drawtext -n @pe 0 10 10 Particles: $calc($hget(particles,0).item / 9)
if (%pe.intro) drawtext -n @pe 0 45 100 Click here to make particles
;if ($mouse.x != $null && $mouse.y != $null) drawtext -n @pe 0 250 10 $mouse.x $mouse.y
;###Draw Paricles###
var %x = 1
while (%x < 100) {
if ($hget(particles,$+(color.,%x))) {
hinc particles $+(ys.,%x)) $hget(particles,$+(grav.,%x))
hinc particles $+(x.,%x) $hget(particles,$+(xs.,%x))
hinc particles $+(y.,%x) $hget(particles,$+(ys.,%x))
hdec particles $+(life.,%x)) 1
if ($hget(particles,$+(life.,%x)) <= 0) {
hdel -w particles $+(*,.,%x)
}
else drawrect -nrf @pe $hget(particles,$+(color.,%x)) 1 $hget(particles,$+(x.,%x)) $hget(particles,$+(y.,%x)) $hget(particles,$+(size.,%x)) $hget(particles,$+(size.,%x))
}
inc %x
}
;###End Draw Paricles###
;###Draw Menu###
drawline -n @pe 0 3 0 200 320 200
drawfill -n @pe 1 0 1 210
drawtext -n @pe 4 10 210 Red
drawtext -n @pe 9 10 225 Green
drawtext -n @pe 12 10 240 Blue
drawtext -n @pe 0 10 255 Speed1
drawtext -n @pe 0 10 270 Speed2
drawtext -n @pe 0 10 285 Amount
drawtext -n @pe 0 10 300 Size
drawline -nr @pe $rgb(%pe.red,%pe.green,%pe.blue) 3 60 217 160 217
drawline -nr @pe $rgb(%pe.red,%pe.green,%pe.blue) 3 60 232 160 232
drawline -nr @pe $rgb(%pe.red,%pe.green,%pe.blue) 3 60 247 160 247
drawline -n @pe 0 3 60 262 160 262
drawline -n @pe 0 3 60 277 160 277
drawline -n @pe 0 3 60 292 160 292
drawline -n @pe 0 3 60 307 160 307
drawline -n @pe 1 1 60 217 160 217
drawline -n @pe 1 1 60 232 160 232
drawline -n @pe 1 1 60 247 160 247
drawline -n @pe 1 1 60 262 160 262
drawline -n @pe 1 1 60 277 160 277
drawline -n @pe 1 1 60 292 160 292
drawline -n @pe 1 1 60 307 160 307
drawrect -n @pe 0 1 $calc(60 + (%pe.red / 2.55)) 212 3 11
drawrect -n @pe 0 1 $calc(60 + (%pe.green / 2.55)) 227 3 11
drawrect -n @pe 0 1 $calc(60 + (%pe.blue / 2.55)) 242 3 11
drawrect -n @pe 0 1 $calc(60 + %pe.mnspeed) 257 3 11
drawrect -n @pe 0 1 $calc(60 + %pe.mxspeed) 272 3 11
if (%pe.parttype == 1) drawrect -n @pe 0 1 $calc(60 + %pe.amount) 287 3 11
else drawrect -n @pe 0 1 $calc(60 + %pe.amount * 10) 287 3 11
drawrect -n @pe 0 1 $calc(60 + %pe.size) 302 3 11
drawtext -n @pe 0 175 210 Grav
drawline -n @pe 0 3 190 230 190 280
drawline -n @pe 1 1 190 230 190 280
drawrect -n @pe 0 1 185 $calc(254 + %pe.gravity * 25) 11 3
drawdot -n @pe 0 5 230 220
drawdot -n @pe 0 5 230 235
drawtext -n @pe 0 240 210 Explosion
drawtext -n @pe 0 240 225 Stream
if (%pe.parttype == 1) drawdot -n @pe 1 3 230 220
if (%pe.parttype == 2) {
drawdot -n @pe 1 3 230 235
drawdot -n @pe 0 30 265 270
drawdot -n @pe 1 28 265 270
;var %ang = $calc($pe.getangle(265,280,$mouse.x,$mouse.y) * -1)
;%pe.angle = %ang
drawline -n @pe 0 2 265 270 $calc(264 + (-28 * $cos(%pe.angle).deg)) $calc(269 + (-28 * $sin(%pe.angle).deg))
drawtext -n @pe 0 185 300 nozzle
drawline -n @pe 0 3 238 307 288 307
drawline -n @pe 1 1 238 307 288 307
drawrect -n @pe 0 1 $calc(238 + %pe.nozzle) 302 3 11
if ($mouse.x && $mouse.y && $mouse.y < 200) {
var %i = %pe.amount
while (%i) {
if ($r(0,1)) {
var %noz = $r(0,%pe.nozzle)
}
else var %noz = $calc($r(0,%pe.nozzle) * -1)
if ($r(0,5) == 5) createparticle $rgb(%pe.red,%pe.green,%pe.blue) %pe.size $calc($mouse.x - %pe.size / 2) $calc($mouse.y - %pe.size / 2) $calc(%pe.angle + 180 + %noz) $r(%pe.mxspeed,%pe.mnspeed) %pe.life %pe.gravity
dec %i
}
}
}
drawrect -n @pe 0 1 304 0 15 15
drawline -n @pe 0 1 305 0 319 14
drawline -n @pe 0 1 304 14 318 0
;###End Draw Menu###
drawdot @pe
.timerpe -o 1 0 pe.loop
}
;GetAngle by BlueThen
alias -l pe.getangle {
%p1.x = $1 | %p1.y = $2 | %p2.x = $3 | %p2.y = $4 | %p3.x = %p2.x | %p3.y = %p1.y | %opposite = $sqrt($calc((%p2.x - %p3.x)^2 + (%p2.y - %p3.y)^2))
%hypotenuse = $sqrt($calc((%p2.x - %p1.x)^2 + (%p2.y - %p1.y)^2)) | %angle = $asin($calc( %opposite / %hypotenuse )).deg
if (%p1.y < %p2.y) %angle = $calc(360 - %angle) | if ((%p1.x > %p2.x) && (%p1.y > %p2.y)) %angle = $calc(180 - %angle)
elseif ((%p1.x > %p2.x) && (%p1.y < %p2.y)) %angle = $calc(180 +(360 - %angle)) | return $calc(%angle - 180)
}