My code:
Code: Select all
void update(Graphics& gfx)
{
for (int x = 0; x < 7; x++)
{
for (int y = 0; y < 6; y++)
{
gfx.DrawRectDim(p1.potX, p1.potY, 5, 5, Colors::Red);
if (map[x][y] == 1)
{
if (p1.potX >= x * 50 && p1.potX <= ((x * 50) + 50))
{
if (p1.potY >= y * 50 && p1.potY <= ((y * 50) + 50))
{
gfx.DrawRectDim(x * 50, y * 50, 50, 50, Colors::Cyan);
}
}
else
{
gfx.DrawRectDim(x * 50, y * 50, 50, 50, Colors::Magenta);
p1.update();
}
}
else
{
gfx.DrawRectDim(x * 50, y * 50, 50, 50, Colors::Green);
}
}
}
}
Code: Select all
#include "Player.h"
void Player::update(bool canUpdate)
{
if (rayPos > 500.0f)
{
rayPos = 0.0f;
}
if (angle > 180.0f)
{
angle = -180.0f;
}
if (canUpdate)
{
potX = x + cos(angle) * rayPos;
potY = y + sin(angle) * rayPos;
rayPos += 50.0f;
}
Here is the solution if you want be get fucky: