Making Fireworks in c++ using basic code
Hello! If anyone can explain me the logic of creating basic fireworks in C++. I have to make the firework swirl though. If someone can guide me what header files to use, and a bit of the logic, it would be a great help!
Voters
badst
opengl?
azula21
@pepelaugh uhhh! no, I can not use that, sadly
edit: using ascii values.
edit: using ascii values.
azula21
@pepelaugh can't use that either dude. That is the main issue. Do you know any way which I can use to make my firework look like its going from the bottom to the top?
azula21
@pepelaugh swirls growing larger would be even great, an ascii piece going up would be enough too..
Thankyou in advance!
Thankyou in advance!
badst
@azula21 simplest possible way is to have a folder of files which contain frames of fireworks, and for each frame, clear the terminal and cout the next file to the terminal.
if you want it to be generated, i'd say you'd have to calculate the vector between the edge of the screen and the center of the firework, and increase the edge of the firework by the vector.
azula21
@pepelaugh It may seem weird but I can't use vector eithers, actually only arrays, loops, ascii and basic stuff for that.
However, thanks a lot for the contribution.
However, thanks a lot for the contribution.
xxpertHacker
@azula21 Is this a school assignment or what?
How experienced are you with C++?
How experienced are you with C++?
azula21
@xxpertHacker, im good with basics, loops arrays and stuff, and yes its an assignment!
CSharpIsGud
@azula21 Just use fixed size arrays, you don't need vectors or anything
azula21
@CSharpIsGud any idea how can I print those so that it looks it goes from the bottom to the top?
badst
@xxpertHacker @CSharpIsGud @azula21 Here, use this as a start:
#include <iostream> #include <array> int main() { std::array<std::string,4> frames = { "Frame1", "Frame2", "Frame3", "Frame4" }; for(auto & frame : frames){ std::cout << frame; } }
Replace "Frame1","Frame2",etc with animation frames.
Then add a sleep function and clear the console.
azula21
@pepelaugh Thanks alot! I'll try that!
xxpertHacker
@pepelaugh A sleep function would require threading, would it not? Or maybe there's a simple blocking way to cause a delay?
xxpertHacker
@pepelaugh Well, if they can't use "advanced" stuff, and if it's for a school assignment, they might not be able to use... either.
All depends on the teacher/course though.
badst
@xxpertHacker yeah, the school wants them to disable the cpu for sleep, lmao.
To be honest, I doubt any school will restrict "advanced" code, that's just weird.
xxpertHacker
@pepelaugh Thankfully my teachers never said "no, you haven't learned that, so you're not allowed to use it", but I've heard of plenty doing just that.
btw, if you're taking that array approach, you'll probably want to be using raw strings instead of "normal" strings:
It'll make your life a bit easier.