Giter Site home page Giter Site logo

filipedeschamps / doom-fire-algorithm Goto Github PK

View Code? Open in Web Editor NEW
1.3K 39.0 282.0 100.01 MB

Playground for the fire effect from DOOM. Really simple algorithm and all experiments are welcome!

License: MIT License

JavaScript 77.66% HTML 4.94% CSS 0.89% Rust 1.07% C++ 3.19% Lua 0.21% Kotlin 1.47% Makefile 0.07% C 0.70% CMake 0.07% Elixir 0.78% Python 1.78% Go 0.24% Java 2.02% QMake 0.12% Shell 0.32% C# 0.97% Dart 1.39% Swift 1.31% Pascal 0.80%

doom-fire-algorithm's Introduction

Doom Fire Algorithm Playground

A playground of experiments related to the Doom fire effect implemented in JavaScript. Feel free to submit your experiment with a Pull Request.

Experiments

These people are making this repository MORE THAN AWESOME.

Contributors


@leocavalcante

@mccraveiro

@AcePetrucci

@eduardosilvapereira

@brunooomelo

@lucianopf

@moog

@WhoisBsa

@mmoraisa

@SharkSharp

@agaelema

@hfabio

@wesleycsj

@kassiano

@mrcsxsiq

@alvesleonardo

@kevinbreaker

@igorantun

@felipe-pita

@edusporto

@herbstrith

@filipealvesdef

@crgimenes

@vinidg

@fabiodelabruna

@rattones

@guidefloripa

@ayang64

@lucasew

@DayllonXavier

@MainDuelo

@viniSaab

@pogist

@FelipeAngelini

@leonampd

@osmarjunior

@jotave42

@urielkdev

@SamuelHiroyuki

@sfadiga

@valescaf

@WeslleyNasRocha

@cabonamigo

@abraaolevi

@AntonioPedro9

@jshlw

@aschiavon91

@gustavo-tp

@aldrie

@thadeucity

@jhonathan93

@SamuelNunes

@franck-gaspoz

@FranciscoCharles

@RisingThumb

@mak213k

@BeatrizAguillera

Author


@filipedeschamps

doom-fire-algorithm's People

Contributors

agaelema avatar aldrie avatar alvesleonardo avatar antoniopedro9 avatar ayang64 avatar caioferrarezi avatar dayllonxavier avatar edusporto avatar felipe-pita avatar filipealvesdef avatar filipedeschamps avatar franciscocharles avatar guidefloripa avatar jhonathan93 avatar leocavalcante avatar leonampd avatar lucianopf avatar mrcsxsiq avatar osmarjunior avatar pserey avatar risingthumb avatar samueldacostaaraujonunes avatar samuelhiroyuki avatar sfadiga avatar thadeucity avatar urielkdev avatar valescaf avatar vinidg avatar vinisaab avatar whoisbsa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

doom-fire-algorithm's Issues

Why not use Canvas?

Hi Filipe, congrats for your project man, is very cool!

By the way, have you thought about using Canvas instead of drawing inside a DIV? I'm saying this because, from experience, canvas performes better for this type of application. As you can see in this example, the frame rate is not very stable. I did a test refactoring part of my code to use canvas and the gain was very expressive.

Cheers.

I had an idea to cover all implementations in this repository :)

What do you think:

  1. Rename this repository to doom-fire-playground
  2. For each implementation, create an isolated and self-contained directory, for example
    • original-implementation-with-table
    • render-engine-architecture
    • render-with-canvas
    • canvas-with-wind-control
  3. To avoid name clashing, we should use something like what we do with migrations files, for example:
    • 2019-01-04-original-implementation-with-table
    • 2019-01-04-render-engine-architecture
    • 2019-01-05-render-with-canvas
    • 2019-01-17-canvas-with-wind-control
  4. Since you will have your own directory, you could add a README.md file if you wish to explain your implementation.

After this, I can even create a video about this playground or transform this repository into a tutorial to encourage developers to try something, since any experiment will be valid :)

Let's do this? 👍

@leocavalcante @mccraveiro @AcePetrucci @brunooomelo @eduardosilvapereira @lucianopf @madureira @ninja85a

Não precisa chamar o renderFire() na função start()

Eu deletei o [i]renderFire()[/i] da função [i]start()[/i] e renderizou da mesma forma.

const firePixelsArray = []
const fireWidth = 60
const fireHeight = 60
const fireColorsPalette = [{"r":7,"g":7,"b":7},{"r":31,"g":7,"b":7},{"r":47,"g":15,"b":7},{"r":71,"g":15,"b":7},{"r":87,"g":23,"b":7},{"r":103,"g":31,"b":7},{"r":119,"g":31,"b":7},{"r":143,"g":39,"b":7},{"r":159,"g":47,"b":7},{"r":175,"g":63,"b":7},{"r":191,"g":71,"b":7},{"r":199,"g":71,"b":7},{"r":223,"g":79,"b":7},{"r":223,"g":87,"b":7},{"r":223,"g":87,"b":7},{"r":215,"g":95,"b":7},{"r":215,"g":95,"b":7},{"r":215,"g":103,"b":15},{"r":207,"g":111,"b":15},{"r":207,"g":119,"b":15},{"r":207,"g":127,"b":15},{"r":207,"g":135,"b":23},{"r":199,"g":135,"b":23},{"r":199,"g":143,"b":23},{"r":199,"g":151,"b":31},{"r":191,"g":159,"b":31},{"r":191,"g":159,"b":31},{"r":191,"g":167,"b":39},{"r":191,"g":167,"b":39},{"r":191,"g":175,"b":47},{"r":183,"g":175,"b":47},{"r":183,"g":183,"b":47},{"r":183,"g":183,"b":55},{"r":207,"g":207,"b":111},{"r":223,"g":223,"b":159},{"r":239,"g":239,"b":199},{"r":255,"g":255,"b":255}]


function hell() {
  createFireDataStructure() 
  createFireSource()
  console.log(firePixelsArray)

  setInterval(calculateFirePropagation, 45.7)

}

function createFireDataStructure() {

  const numberOfPixels = fireWidth * fireHeight

  for (let i = 0; i < numberOfPixels; i++) {

    firePixelsArray[i] = 0
}

}
function calculateFirePropagation() {

  for (let column = 0; column < fireWidth; column++) {

    for (let row = 0; row < fireHeight; row++) {

     const pixelIndex = column + fireWidth * row
     updateFireIntensityPerPixel(pixelIndex)

}
}
renderFire()
}

function updateFireIntensityPerPixel(currentPixelIndex) {
  const belowPixelIndex = currentPixelIndex + fireWidth
    if (belowPixelIndex >= fireWidth * fireHeight) {
      return
}
const decay = Math.floor(Math.random() * 2.4)

const belowPixelFireIntensity = firePixelsArray[belowPixelIndex]
const newFireIntensity = belowPixelFireIntensity - decay >= 0 ? belowPixelFireIntensity - decay : 0
firePixelsArray[currentPixelIndex - decay] = newFireIntensity

}
function renderFire() {
  debug = false
  let html = '<table cellpadding=0 cellspacing=0>'
  for (let row = 0; row < fireHeight; row++) {

    html += '<tr>'
    for (let column = 0; column < fireWidth; column++) {

      const pixelIndex = column + fireWidth * row
      const fireIntensity = firePixelsArray[pixelIndex]

      if (debug === true) {
        html += '<td>'
       
html += `<div class="pixel-index">${pixelIndex}</div>`
        html += fireIntensity
        html += '</td>'

} else {
  const color = fireColorsPalette[fireIntensity]
  const colorString = `${color.r},${color.g},${color.b}`
  html += `<td class="pixel" style="background-color:rgb(${colorString});">`
  html += '</td>'
}

}

html += '</tr>'

}

html += '</table>'
document.querySelector('#welcomeHell').innerHTML = html

}

function createFireSource() {

  for (let column = 0; column <= fireWidth; column++) {

    const overflowPixelIndex = fireWidth * fireHeight
    const pixelIndex = (overflowPixelIndex - fireWidth) + column
    firePixelsArray[pixelIndex] = 36

}

}

hell()`

Erro ao acessar o domínio dos exemplos

Por algum motivo muito maluco que eu não estou conseguindo entender, quando acesso a URL:

https://filipedeschamps.github.io/doom-fire-algorithm/playground/1st-implementation-with-tables/

(note que está dentro do domínio do Github)

Ele redireciona para:

https://filipedeschamps.com.br/doom-fire-algorithm/playground/1st-implementation-with-tables

E dentro das configurações do repositório, ele mostra que está fazendo o deploy para o meu domínio (coisa que eu nunca configurei, tanto que todos os links no README eram para github.io

image

Preciso de ajuda

Alguém faz ideia de como remover um domínio customizado? Eu não tenho nada no meu DNS que faça esse redirecionamento (e até porque, eu não controlo o DNS do github.io

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.