Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I do a fire effect in 9 lines?
#1
Big Grin
Antoni
Reply
#2
Hmmm - I need a buffer for my fire effect...

Let me try it harder Wink
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#3
I saw it first! :x
Antoni
Reply
#4
???

Closes lips....

I wouldn't post it if I think it to be impossible. Hey you made a darn 3dstarfield and a Floormapper in 9 lines!!!!!

And here I see you try to ask for a fire? LOL

PS. A fire fx would take less cal that my translucent plasma!!!

*Rel Spanks Antoni....

*but....

* Wow!!! Its the invasion of the Spanish Armada!!!!!

Viva España!!!!
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#5
buffer? nah. you need to draw a row of random (255 or 0) pixels at the bottom, and consistantly shift up and average the above pixels. one trick to cut down on space is to when you average, average the pixels surrounding the bottom one so you dont need extra lines to shift the image up. if you could do it in 9, it'd be a squeeze. but i'll play with the idea using some of the hacks (string variables, etc) y'all have come up with.
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply
#6
I've tried to do that and I can't. Y'know, I wanted to show you my impressive fire routine, which has some odd twists and deinitely looks better than any fire I've seen. It has averages, but not in the plain way... And it needs to draw a new frame without altering the previous, 'cause it does a 3x3 matrix convolution:

Code:
// MEGAFIRE by NATHAN 2000

#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <mem.h>

#define pon_punto(x,y,c) (pantalla[x+(y<<8)+(y<<6)]=c)
#define FALSO 0
#define CIERTO !FALSO

typedef short LOGICO;

typedef struct
{
   unsigned char r;
   unsigned char g;
   unsigned char b;
}RGB;

typedef RGB PALETA[256];

unsigned char lee_punto(int x ,int y)
{
   return(peekb(0xA000,x+(y<<6)+(y<<8)));
}

void fuego1(void)
{
   PALETA paleta;
   PALETA negra;
   unsigned char *buffer,*pantalla;
   unsigned int i;
   int x,y;
   int punto;
   int paso=0;
   LOGICO terminado=FALSO;
   LOGICO acabando=FALSO;

   buffer=(unsigned char *) malloc (16000);

   pantalla=(unsigned char *) malloc (16000);

   asm mov ax,0x13
   asm int 0x10

   for(i=0;i<45;i++)
   {
      paleta[i].r=63;
      paleta[i].g=63;
      paleta[i].b=63-(64*i)/45;
   }

   for(i=45;i<150;i++)
   {
      paleta[i].r=63;
      paleta[i].g=63-(64*(i-45))/105;
      paleta[i].b=0;
   }

   for(i=150;i<256;i++)
   {
      paleta[i].r=63-(64*(i-150))/106;
      paleta[i].g=0;
      paleta[i].b=0;
   }

   for(i=0;i<256;i++)
   {
      negra[i].r=0;
      negra[i].g=0;
      negra[i].b=0;
      outportb(0x3C8,i);
      outportb(0x3C9,0);
      outportb(0x3C9,0);
      outportb(0x3C9,0);
   }

   // Borro el buffer:
   for(i=0;i<16000;i++)
   {
      buffer[i]=0;
      pantalla[i]=0;
      pokeb(0xA000,16000+i,255);
      pokeb(0xA000,32000+i,255);
   }

   // Pinta bordecitos.
   for(i=50;i<150;i++)
   {
      pokeb(0xA000,320*i,0);
      pokeb(0xA000,320*i+319,0);
      pokeb(0xA000,320*i+1,150);
      pokeb(0xA000,320*i+318,150);
   }

   do
   {
      if(kbhit())
      {
         getch();
         acabando=CIERTO;
         paso=0;
      }


      // Pinto algunos 'focos' en la l¡nea base:
      for(i=0;i<20;i++)
         pon_punto(random(320),48,255);

      if(paso<115) paso++;

      if(paso>=50 && paso<114 && !acabando)
         for(i=0;i<256;i++)
         {
            if(negra[i].r<paleta[i].r) negra[i].r++;
            if(negra[i].g<paleta[i].g) negra[i].g++;
            if(negra[i].b<paleta[i].b) negra[i].b++;

            outportb(0x3C8,i);
            outportb(0x3C9,negra[i].r);
            outportb(0x3C9,negra[i].g);
            outportb(0x3C9,negra[i].b);
         }

      if(acabando)
      {
         for(i=0;i<256;i++)
         {
            if(negra[i].r>0) negra[i].r--;
            if(negra[i].g>0) negra[i].g--;
            if(negra[i].b>0) negra[i].b--;

            outportb(0x3C8,i);
            outportb(0x3C9,negra[i].r);
            outportb(0x3C9,negra[i].g);
            outportb(0x3C9,negra[i].b);
         }
         if(paso==64) terminado=CIERTO;
      }

      // Desenfoca desplazando lo que hay en pantalla a buffer:
      for(y=1;y<49;y++)
      {
         for(x=1;x<319;x++)
         {
            punto=pantalla[x+(y<<8)+(y<<6)];
            punto+=pantalla[x+((y-1)<<8)+((y-1)<<6)];
            punto+=pantalla[x+1+((y-1)<<8)+((y-1)<<6)];
            punto+=pantalla[x+1+(y<<8)+(y<<6)];
            punto+=pantalla[x+1+((y+1)<<8)+((y+1)<<6)];
            punto+=pantalla[x+((y+1)<<8)+((y+1)<<6)];
            punto+=pantalla[x-1+((y+1)<<8)+((y+1)<<6)];
            punto+=pantalla[x-1+(y<<8)+(y<<6)];
            punto+=pantalla[x-1+((y-1)<<8)+((y-1)<<6)];
            punto/=8;
            if(punto<0)
               punto=0;
            else if(punto>255)
               punto=255;
            buffer[x+320*(y-1)]=(unsigned char)punto;
         }
      }

      // Pinto buffer:

      movedata(FP_SEG(buffer),FP_OFF(buffer),0xA000,48000,16000);

      // Pinto buffer al rev‚s:

      for(i=0;i<50;i++)
         movedata(FP_SEG(buffer),FP_OFF(buffer)+320*i,0xA000,320*(49-i),320);

      // Actualizo pantalla:

      movedata(FP_SEG(buffer),FP_OFF(buffer),FP_SEG(pantalla),FP_OFF(pantalla),16000);


   }while (!terminado);

   asm mov ax,0x3
   asm int 0x10

   free(buffer);
   free(pantalla);
}

void main(void) { fuego1();}

See what I mean?
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#7
oh well, beat ya to it Smile

Code:
1 SCREEN 13
2 FOR a = 0 TO 255
3  PALETTE a, a \ 4
4 NEXT a
5 PSET (x, 199), CINT(RND) * 255
6 PSET (x, 198 - i), (POINT(x, 198 - i + 1) + POINT(x + 1, 198 - i + 1) + POINT(x + 1, 198 - i - 1) + POINT(x, 198 - i) + POINT(x, 198 - i + 2)) / 5
7 x = (x + 1) MOD 320
8 IF x = 0 THEN i = (i + 1) MOD 98
9 IF INKEY$ = "" THEN GOTO 5

slow as molasses and ugly as hell, but it's fire.
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply
#8
Doing it the way you typed it you forgot to lable your line. It doesn't know where to go, but I could be very wrong. So do the 9 lines work here or is there another way? :???:
Reply
#9
*slaps forehead*
blame that on word wrap, not me. and here's a much faster edition:
Code:
1 SCREEN 13
2 FOR x% = 0 TO 127
3 PALETTE x%, x% \ 2
4 NEXT x%
5 DEF SEG = &HA7D0
6 FOR x% = 31999 TO 0 STEP -1
7 IF x% >= 31680 THEN POKE x%, CINT(RND * 127) ELSE POKE x%, (PEEK(x% + 320) + PEEK(x% + 319) + PEEK(x% + 321) + PEEK(x%) + PEEK(x% + 640)) \ 5
8 NEXT x%
9 IF INKEY$ = "" THEN GOTO 5
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply
#10
the 'c' source above has been converted/shrinked to 11 lines in QB by Phobeous and me: take a glance at the challenge section Wink
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)