I appreciate your help, but I don't think this is the issue. if(check_walls(cell, &cur_x, &cur_y) == false is actually satisfied. Whenever i run the program, in fact, it seems always returns false. The check_walls function is used to test if there are any available neighbors of the current cell. If there are it changes cur_x and cur_y. If there are none, it is supposed to iterate through vector until it wither finds a cell that returns true when passed into check_walls, or until it runs out of cells.
if (upblock == true && leftblock == true && downblock == true
&& rightblock == true) {
*x = ori_x;
*y = ori_y;
std::cout << "Checkwalls returns false" << std::endl;
return false;
}
I don't understand why you say this can't be satisfied. If all four of the cells surrounding the current cell are blocked, it should set all four of those bools to true and return false.

Thanks for replying Rutin!
Here is the github repository for the project: https://github.com/Starfruit64/Paladin
Im not 100% if this is what you were asking for, so if it's not just say. And no, I'm not using Visual Studio, I'm using Eclipse. (p.s I'll keep what you said about initializing variables in mind)

About events: should I remove the Input class and have all events handles in Main in a function? Or should I have multiple times where I poll for events, one time for input, one time for window events, etc.?

Hello! I have made a clone of Tetris using SDL libraries for C++. I would love to get some input as to what I have done right and wrong. Also please tell me if im using Github correctly, it confuses me greatly. (I tried to add a new commit to remove the misplaced header file "DungeonCrawlV4.o" but it doesn't seem to have taken place.)
https://github.com/Starfruit64/Tetris-Clone

I've heard from many places (including this website) a really helpful thing you can do as a beginner is have someone review your game code, and to go back and update it using peoples suggestions. Are there any good websites for this that is open to beginners?

Even when i convert the degrees to radians the laser is still off. I think this is because you though that x and y were the center of the bullet rect, but it is actually the upper left-hand corner. I tried adding 1/2 ship_width to the offset x but this doesnt help. How should I adjust my code? Thanks.

When I try this code it only amplifies the problem. The bullet is very far off from the ship, and when the player rotates the ship the bullet sporadically moves close and away from the ship. I don't understand why multiplying the width of the ship divided by two by the angle would help at all to be honest.

I am making a basic "space shooter" game to test myself. I am using SDL external library in c++ to make it. I have a class called "Bullet" and a vector of Bullet objects. I als o have a class called "Ship", which is the player. When the player shoots, one of the Bullet objects is teleported to the player and given the angle of the player. The problem is that when the player is to the side the bullet is off-center. Can anybody help me? Here is my code for my class:
void Bullet::shoot(float ship_x, float ship_y, float ship_angle, int ship_width){
x = ship_x + (ship_width/2) - (width/2);
y = ship_y;
angle = ship_angle;
}
When the ship is pointing up (0 degree angle) or down (180 degree angle) than the bullet spawns perfectly. But the more away it gets from those the more off kilter it gets. Any thought?

I am trying to make a top down space shooter thing in SDL. I am trying to move the ships rect so that it goes forward at the angle the ship is at. From what I have read, in order to do this would do something like:
rect.y -= sin( angle*( PI/180 ) ) * speed;
rect.x -= cos( angle*( PI/180 ) ) * speed;
Is this what I should do? Because when I add this to my loop, the ship moves in the opposite direction, and the movement is usually curved, not straight. And if the angle is set to 0, the ship moves sideways. Any help is appreciated.

Hello, I am making a simple little text-based RPG/Dungeon Crawler game to help me practice C++. But I have come across an odd bug. I have narrowed it down to this bit of code:
...more code
cout << "A " << name << " attacks!" << endl;
//Checks who attacks first
int initiative = rand() % 2;
if(initiative == 0){
cout << "The " << name << " strikes first!" << endl;
int damage = (rand() % max + min);
hp =- damage;
cout << endl;
cout << "The " << name << " dealt " << damage << " points of damage!" << endl;
}
string bin;
cout << "Press any key to continue > " << flush;
cin >> bin;
system("cls");
//Combat loop
while(true){
...more code
If initiative = 1, than the program works like its supposed to: the enemy doesn't attack first and after the user inputs something after "Press any key to continue" the game continues on. But if initiative = 0 than it gets weird. It displays the "Enemy struck first...enemy dealt x damage" etc. but when the user enters input after it prompts "Press any key to continue" the program just enters an infinite loop with no text on screen. Any ideas as to why this could be happening?