Author Topic: Flames tutorial  (Read 49300 times)

0 Members and 4 Guests are viewing this topic.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Flames tutorial
« Reply #60 on: January 28, 2012, 07:20:27 am »
That's surely a great tutorial, but I haven't really understood how to burn only one sprite, in a big screen with several others ???
« Last Edit: January 28, 2012, 07:24:46 am by Matrefeytontias »

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Flames tutorial
« Reply #61 on: January 28, 2012, 07:42:26 am »
That is tough and it depends... Pretty much, as builder said, the basics are this:
-you shift the pixels up one
-you give it a chance to disappear (For example, 1/8 chance)

Depending on the sprite situation, you will probably have to use 2 For( loops to check each pixel of the sprite as well as giving it an upper limit (like the flames can only go as high as another 8 pixels)

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Flames tutorial
« Reply #62 on: January 28, 2012, 08:47:32 am »
Right now, I have a sprite moved by the player, and an inanimated block which I want him to burn. How must I do it ?

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Flames tutorial
« Reply #63 on: January 28, 2012, 10:09:23 am »
okay, I am not sure if this will work as I am not much of an Axe coder, but maybe try this?
Code: [Select]

For(B,X,X+7
For(C,Y+1,Y+15
pxl-Test(C,B→A
pxl-Off(C-1,B
If rand^8
pxl-On(C-1,B
End
End

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Flames tutorial
« Reply #64 on: January 28, 2012, 10:12:50 am »
pxl-Test returns 0 if the pixel tested is off or 1 if it's on o_O what do you do with this command ?

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Flames tutorial
« Reply #65 on: January 28, 2012, 10:14:27 am »
Oops, let me modify that XD:
Code: [Select]

For(B,X,X+7
For(C,Y+1,Y+15
pxl-Off(C-1,B
If rand^8*pxl-Test(C,B
pxl-On(C-1,B
End
End

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Flames tutorial
« Reply #66 on: January 28, 2012, 10:19:28 am »
It doesn't work :/

Here it is the full code I use :
Code: [Select]
44->X-16->Y

Repeat getkey(15)
 Pt-On(X,Y,[FFFFFFFFFFFFFFFF
 For(B,X,X+7)
  For(C,Y+1,Y+15)
   Pxl-Off(C-1,B
   If rand^8*pxl-Test(C,B)
    Pxl-On(C-1,B
   End
  End
 End
 DispGraph
End

Offline MGOS

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +95/-0
    • View Profile
Re: Flames tutorial
« Reply #67 on: January 28, 2012, 10:26:11 am »
It burns the pixels below the block. You'd have to do this:

Code: [Select]
44->X-16->Y

Repeat getkey(15)
 Pt-On(X,Y,[FFFFFFFFFFFFFFFF
 For(B,X,X+7)
  For(C,Y-7,Y+7)  //I changed this line
   Pxl-Off(C-1,B
   If rand^8*pxl-Test(C,B)
    Pxl-On(C-1,B
   End
  End
 End
 DispGraph
End

No guarantee, but I hope it works.
« Last Edit: January 28, 2012, 10:26:37 am by MGOS »

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Flames tutorial
« Reply #68 on: January 28, 2012, 10:32:37 am »
it doesn't work anymore >_< but I don't know why, it seems that it would be ok o_O

EDIT : I just found what's wrong :
Code: [Select]
44->X-16->Y

Repeat getkey(15)
 Pt-On(X,Y,[FFFFFFFFFFFFFFFF
 For(B,X,X+7)
  For(C,Y-7,Y+7)  //I changed this line
   Pxl-Off(B,C-1     <----------------------- Here
   If rand^8*pxl-Test(B,C) <---------------- Here
    Pxl-On(B,C-1    <------------------------ and Here
   End
  End
 End
 DispGraph
End

That's why instead of Grammer, the Axe commands Pxl-xxx give the X as first argument and Y as second xD
« Last Edit: January 28, 2012, 10:41:47 am by Matrefeytontias »

Offline MGOS

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +95/-0
    • View Profile
Re: Flames tutorial
« Reply #69 on: January 28, 2012, 10:45:48 am »
Yeah, ninja'd again.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Flames tutorial
« Reply #70 on: January 28, 2012, 10:46:58 am »
But, I've had the time to put a +1 at your message XD

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Flames tutorial
« Reply #71 on: January 28, 2012, 12:06:50 pm »
So did my code work, otherwise?

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Flames tutorial
« Reply #72 on: January 28, 2012, 12:13:34 pm »
Yes, that's a great code, thanks :thumbsup: and you can make the flame longer by changing the second For loop (and I found that rand^6 is better than rand^8)

Offline MGOS

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +95/-0
    • View Profile
Re: Flames tutorial
« Reply #73 on: January 28, 2012, 12:48:32 pm »
Yes, that's a great code, thanks ;D and you can make the flame longer by changing the second For loop (and I found that rand^6 is better than rand^8)

The number you subtract in the for loop is the height of the flames -1.
This would make the flames 16 pixels high
Code: [Select]
For(C,Y-15,Y+7)
Changing the modulus at the rand will change the density of the flames. A high number like 8 or 10 will let the flames have more particles than having a small number like 4 or 6.

Code: [Select]
If rand^10*pxl-Test(B,C)  //High density = more particles
...
If rand^4*pxl-Test(B,C)  //Low density = less particles

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Flames tutorial
« Reply #74 on: January 28, 2012, 01:28:21 pm »
Yeah, that's it