Answer the question
In order to leave comments, you need to log in
How to throw a beam?
I'm making a 3D game, please don't pay attention to the title of the question, just qna.habr.com has too strict rules for creating a title, I need to make a ray throw function that will return the color of the object, so far no lighting needs to be done, just a ray throw and it cube collision:
#include <cstdlib>
#include <SFML/Graphics.hpp>
using namespace std;
using namespace sf;
int WIDTH=800;
int HEIGHT=600;
int bits_per_pixel=32;
/*
*
*/
Color cast_ray() {
return Color(0,0,0);
}
int main(int argc, char** argv) {
RenderWindow window(VideoMode(WIDTH,HEIGHT,32),"GAME");
while(window.isOpen()){
Event event;
while(window.pollEvent(event)){if(event.type==Event::Closed){window.close();}}
window.clear(Color(100,200,255,0));
RectangleShape floor(Vector2f(WIDTH,HEIGHT/2));
floor.setPosition(0,HEIGHT/2);
floor.setFillColor(Color(150,100,100));
window.draw(floor);
window.display();
}
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question