New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python-like Doom Fire Algorithm #38
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add canvas rendering using drawRect
fix: increase canvas size, decrease decay and remove debug mode
New architecture proposal
…o-home feat: add @lucianopf implementation to home index
Render with PixiJS
Render using canvas image
Mccraveiro canvas fixes
fix: invert fire controls from mccraveiro experiment
feat: add experiment authors to home index
rust: add algorithm to render in terminal
feat: add @moog experiment to home index
fix: add better instructions for Falling Stars experiment
Added a C++ implementation using SFML to the algorithm
feat: add elixir terminal version
This is responsible for a nice and flexible way to attributing colors for an object that uses it. In future I pretend to implement some linear interpolation here for adding some fancy color effects, just like smoothly changing from the current color palette to a target color palette. Some ideas would be welcome :)
This was implemented as an abstract base class and the render method have to implement by a child class. Thus the user have the flexibility to choose which library will be used for rendering the fire.
This class inherits all the methods and attributes from DoomFire abstract base class. Besides that, implements the render method using the pygame library.
This application implements an example of DoomFirePygame. The app controls the fire basically though mouse clicks. Left and right button decreases and increases the fire intensity, respectively and the centerbutton toggles the source fire and the escape key closes the application.
filipedeschamps
force-pushed
the
master
branch
from
February 7, 2019 12:09
531e824
to
31140bf
Compare
…om-fire Pythonic doom fire
Closing this PR in favor of #55 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Não sei se eu fiz o pull request certo, pois não tenho muita experiência nisso :( mas se vc puder organizar o local do arquivo eu agradeço :)
from bs4 import BeautifulSoup
from time import sleep
from random import randint
width = 40
height = 40
f = open("render.html", "r")
fireColorsPallete = [[7, 7, 7],[31, 7, 7],[47, 15, 7],[71, 15, 7],[87, 23, 7],[103, 31, 7],[119, 31, 7],[143, 39, 7],[159, 47, 7],[175, 63, 7],[191, 71, 7],[199, 71, 7],[223, 79, 7],[223, 87, 7],[223, 87, 7],[215, 95, 7],[215, 95, 7],[215, 103, 15],[207, 111, 15],[207, 119, 15],[207, 127, 15],[207, 135, 23],[207, 135, 23],[199, 135, 23],[199, 143, 23],[199, 151, 31],[191, 159, 31],[191, 159, 31],[191, 167, 39],[191, 167, 39],[191, 175, 47],[183, 175, 47],[183, 183, 47],[183, 183, 55],[207, 207, 111],[223, 223, 159],[239, 239, 199],[255, 255, 255],]
def start():
FirePixels = createDataStructure()
renderFire(FirePixels)
createFireSource(FirePixels)
def createDataStructure():
pixArray = []
pixArray = [0 for i in range(width*height)]
return pixArray
def createFireSource(FirePixels):
lastPixel = len(FirePixels)
for collumn in range(width):
source_index = (lastPixel - width) + collumn
FirePixels[source_index] = 36
def calculateFirePropagation(FirePixels):
for collumn in range(width):
for row in range(height):
index = collumn + row*width
if index >= len(FirePixels) - width:
continue
else:
decay = randint(0,2)
FirePixels[index-decay] = FirePixels[index+width] - decay
createFireSource(FirePixels)
if FirePixels[index-decay] < 0:
FirePixels[index-decay] = 0
def renderFire(FirePixels):
'debug = False
html = '
def insertHtml(html):
\n""":html_file = open('render.html','r')
lines = html_file.readlines()
for i, line in enumerate(lines):
if line == """
lines[i] = line +" " + html
if line.startswith(' <table',0,23):
lines.pop(i)
start()
``