Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
22 May, 2013, 02:01:24 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1] 2 3 ... 6   Go Down
  Print  
Author Topic: Flames tutorial -  (Read 4366 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Yesterday at 23:45:26
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642


Topic starter
Total Post Ratings: +589

View Profile
« on: 20 February, 2011, 08:20:16 »
+17

Do you want your title screens to look like this?


If so, go no further because in this tutorial, I will be discussing how to get epic fire effects into your games and title screens using Axe.  This is applicable to either white fire or black fire, with, or without objects in the fire.

The rules of the fire are simple.  Take each pixel, move that pixel up, then also randomly erase pixels.  Since each pixel on the screen has an equal probability of being erased, pixels near the top have a lower probability of being set, because the pixels would have had to travel all the way from the bottom to the top without getting erased.  But thats a lot of mumbo jumbo, lets get straight to the code:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
.Axe
ClrDraw
[FEFDFBF7EFDFBD7F]->Str1  //Each Byte here has 7 bits set and 1 bit not set (like FE is 11111110 in binary)
                      //This is so that we can erase a random pixel, since Axe has no built in way to do that
Line(0,63,95,63       //the pixels to catch fire, explained a little later

Repeat getKey(15)    //until we press clear

For(F,L6+12,L6+767       //loop through all of the screen pixels except the last 12
{F} and {rand^8+Str1}->{F-12}   //take the byte, use AND to erase a single bit from it, and then store it into the byte directly *above* it
End                     //this makes it so that as the byte rises, each frame a pixel is erased from it

DispGraph

End

So why do we need the line command?  Well because this routine needs fuel.  What that means is that if you draw a sprite onto the screen while this routine is running, that sprite will catch fire automatically.  If you stop drawing the sprite, it will rise and vanish like smoke.  Anything you draw onto the part of the screen that is being 'flamed' will automatically catch fire, and will continue to be on fire until you stop drawing it, at which point it will vanish like smoke.  Go ahead try it out!

Also, some of you may want to try a black background with white smoke.  the principles are exactly the same, but everything is inverted.  Instead of FE (11111110), you would use 01 (00000001), and instead of using AND, you would use OR.  Its that simple Smiley
« Last Edit: 21 March, 2011, 09:17:37 by Builderboy » Logged

Darl181
Vy'o'us pleorsdtu tlh'e gjaemue.
Coder Of Tomorrow
LV12 Extreme Poster (Next: 5000)
*
Offline Offline

Gender: Male
Last Login: Today at 00:53:03
Date Registered: 10 June, 2010, 00:32:08
Location: {I*9+L₁+1},{I*9+L₁+3}
Posts: 3272


Total Post Ratings: +267

View Profile WWW
« Reply #1 on: 20 February, 2011, 08:33:10 »
0

Wow, this is awesome Shocked
Now I can make that "light people on fire" game I was going to make a while back Wink

How well would this work for animated sprites?  And is there a way to make only part of the screen (say, a sprite) on fire?
Logged




 
Spoiler for Stuff:



OS 2.43  Boot 1.02  Hardware Rev. B

OS 1.04.32

OS 3.1.0.392  Boot1 3.0.99  Boot2 3.10.16
Spoiler for Misc:
Quote
You'll understand / It's not a shame / To be always / Losing the game / Burma-Shave
"Dynamic userbars!"
Omnimaga radio
Interactive Omnimaga radio
Our World of Text
Draw on websites
Then blow them up
In-browser flight simulator
Haxball: MMO soccer/air hockey game
  Draw with sand.  Yay?
The Game
You just lost the game
Zombo.com
light post color is #dfefff
dark post color is #cae4ff
quote box color is #6699ff
transparent color is...transparent 0.o
Spoiler for Forum search alternative (bookmarklet):
https://www.squarefree.com/bookmarklets/search.html
javascript:q=""+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);if(!q)q=prompt("No%20selected%20text;%20enter%20search%20term.").replace(/\s\+/g,"%252B");if(q!=null)location="http://www.google.com/search?q="+q.replace(/\s+/g,"+")+"+site:"+location.hostname;void(0);
AngelFish
This is my custom title
Administrator
LV12 Extreme Poster (Next: 5000)
*
Offline Offline

Gender: Male
Last Login: Yesterday at 22:48:40
Date Registered: 15 August, 2010, 09:18:54
Posts: 3188


Total Post Ratings: +218

View Profile
« Reply #2 on: 20 February, 2011, 08:37:02 »
0

Wow, this is awesome Shocked
Now I can make that "light people on fire" game I was going to make a while back Wink

How well would this work for animated sprites?  And is there a way to make only part of the screen (say, a sprite) on fire?

Yep. Draw the sprite in two parts (assuming you'll be erasing the sprite every cycle to allow movement).  Draw the first part on the buffer before the For( loop and draw the second part after the For( loop. Only the first part will be on fire. I wouldn't recommend this method for processor intensive games though, because it's slow.
« Last Edit: 20 February, 2011, 08:37:39 by Qwerty.55 » Logged

∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ
Darl181
Vy'o'us pleorsdtu tlh'e gjaemue.
Coder Of Tomorrow
LV12 Extreme Poster (Next: 5000)
*
Offline Offline

Gender: Male
Last Login: Today at 00:53:03
Date Registered: 10 June, 2010, 00:32:08
Location: {I*9+L₁+1},{I*9+L₁+3}
Posts: 3272


Total Post Ratings: +267

View Profile WWW
« Reply #3 on: 20 February, 2011, 08:38:56 »
0

So, I would xor the second sprites back to nothing, I guess?
I could use RecallPic, but that erases the buffer like pt-off...
Logged




 
Spoiler for Stuff:



OS 2.43  Boot 1.02  Hardware Rev. B

OS 1.04.32

OS 3.1.0.392  Boot1 3.0.99  Boot2 3.10.16
Spoiler for Misc:
Quote
You'll understand / It's not a shame / To be always / Losing the game / Burma-Shave
"Dynamic userbars!"
Omnimaga radio
Interactive Omnimaga radio
Our World of Text
Draw on websites
Then blow them up
In-browser flight simulator
Haxball: MMO soccer/air hockey game
  Draw with sand.  Yay?
The Game
You just lost the game
Zombo.com
light post color is #dfefff
dark post color is #cae4ff
quote box color is #6699ff
transparent color is...transparent 0.o
Spoiler for Forum search alternative (bookmarklet):
https://www.squarefree.com/bookmarklets/search.html
javascript:q=""+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);if(!q)q=prompt("No%20selected%20text;%20enter%20search%20term.").replace(/\s\+/g,"%252B");if(q!=null)location="http://www.google.com/search?q="+q.replace(/\s+/g,"+")+"+site:"+location.hostname;void(0);
Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Yesterday at 23:45:26
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642


Topic starter
Total Post Ratings: +589

View Profile
« Reply #4 on: 20 February, 2011, 08:40:02 »
0

@Qwerty that wouldn't work because there is no ClrDraw, so there is no difference between doing it before or after.

It could work very well for animated sprites, and with masking you could make it so that only the top of them is on fire and nothing inside.

However, making only a section of the screen create fire is difficult.  This is a screen effect, not an object effect, so anything that passes into the 'fire field' will catch on fire.  Also, since this is byte based, you would have to make the fire field out of whole bytes, unless you wanted to get into some complicated byte masking.
Logged

AngelFish
This is my custom title
Administrator
LV12 Extreme Poster (Next: 5000)
*
Offline Offline

Gender: Male
Last Login: Yesterday at 22:48:40
Date Registered: 15 August, 2010, 09:18:54
Posts: 3188


Total Post Ratings: +218

View Profile
« Reply #5 on: 20 February, 2011, 08:41:24 »
0

Builder, it wouldn't work? I wonder why it works on my calculator then.
Logged

∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ
Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Yesterday at 23:45:26
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642


Topic starter
Total Post Ratings: +589

View Profile
« Reply #6 on: 20 February, 2011, 08:45:02 »
0

Oh do you XOR it on, and then XOR it off?
Logged

AngelFish
This is my custom title
Administrator
LV12 Extreme Poster (Next: 5000)
*
Offline Offline

Gender: Male
Last Login: Yesterday at 22:48:40
Date Registered: 15 August, 2010, 09:18:54
Posts: 3188


Total Post Ratings: +218

View Profile
« Reply #7 on: 20 February, 2011, 08:45:31 »
0

Not for the front buffer where the flames are.
« Last Edit: 20 February, 2011, 08:47:20 by Qwerty.55 » Logged

∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ
Munchor
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Yesterday at 17:58:01
Date Registered: 16 October, 2010, 15:39:13
Location: Position
Posts: 6209


Total Post Ratings: +174

View Profile
« Reply #8 on: 20 February, 2011, 08:46:25 »
0

Ooooh, nice Builderboy, thanks much Grin
Logged
Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Yesterday at 23:45:26
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642


Topic starter
Total Post Ratings: +589

View Profile
« Reply #9 on: 20 February, 2011, 08:49:52 »
0

Wait do you use the backbuffer then?  I was responding to your original idea, where you just said to do it after the for loop
Logged

AngelFish
This is my custom title
Administrator
LV12 Extreme Poster (Next: 5000)
*
Offline Offline

Gender: Male
Last Login: Yesterday at 22:48:40
Date Registered: 15 August, 2010, 09:18:54
Posts: 3188


Total Post Ratings: +218

View Profile
« Reply #10 on: 20 February, 2011, 08:51:33 »
0

I'm using both buffers for graphics. The front buffer holds part of the sprite and the back buffer holds another part. I tried moving the part from after the For( loop (where there was no fire on the sprite) to before it and fire appeared.
Logged

∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ
Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Yesterday at 23:45:26
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642


Topic starter
Total Post Ratings: +589

View Profile
« Reply #11 on: 20 February, 2011, 08:52:50 »
0

Gotcha, although how are you using both the buffers?  Are you copying from one buffer to another?  Using greyscale?
Logged

AngelFish
This is my custom title
Administrator
LV12 Extreme Poster (Next: 5000)
*
Offline Offline

Gender: Male
Last Login: Yesterday at 22:48:40
Date Registered: 15 August, 2010, 09:18:54
Posts: 3188


Total Post Ratings: +218

View Profile
« Reply #12 on: 20 February, 2011, 08:55:38 »
0

I'm swapping between the normal two buffers and a third buffer, which holds specific data from the first two buffers. Basically, it's just greyscale though.
Logged

∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ
Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Yesterday at 23:45:26
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642


Topic starter
Total Post Ratings: +589

View Profile
« Reply #13 on: 20 February, 2011, 08:56:59 »
0

o.O Gotcha.  Well, to summarize, I was merely responding to your original post, since you didn't say anything about 2 or 3 buffers or anything, I didn't understand ^^
Logged

AngelFish
This is my custom title
Administrator
LV12 Extreme Poster (Next: 5000)
*
Offline Offline

Gender: Male
Last Login: Yesterday at 22:48:40
Date Registered: 15 August, 2010, 09:18:54
Posts: 3188


Total Post Ratings: +218

View Profile
« Reply #14 on: 20 February, 2011, 08:57:56 »
0

I only changed the stuff concerning the front buffer, so I didn't think it was necessary to describe the others.
Logged

∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ
Pages: [1] 2 3 ... 6   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.354 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.