Search found 575 matches

by Yumtard
June 19th, 2018, 1:38 pm
Forum: Everything
Topic: Snake Class Question
Replies: 13
Views: 4351

Re: Snake Class Question

also you will then want apple positions, obstacle positions and what not, so rather than sending a bunch of things to a DrawBoard() you could just have a DrawCell(const vec& pos) Then in Snake:Draw() you loop over the snakes segments and call the boards draw function on their positions. And do the s...
by Yumtard
June 19th, 2018, 1:32 pm
Forum: Everything
Topic: Snake Class Question
Replies: 13
Views: 4351

Re: Snake Class Question

Well you COULD solve it by passing snake as a pointer and do forward declaration. However, in this case you shouldn't. You're including snake in board just to send it to the draw function where you use the snake to get its position. Why not just pass the position to the function? DrawBoard(Graphics&...
by Yumtard
June 19th, 2018, 12:00 pm
Forum: Everything
Topic: Snake Class Question
Replies: 13
Views: 4351

Re: Snake Class Question

I don't think board should be a member of the snake class. You would just need it to draw the snake so just pass it as a reference to the draw function. Also you're including board.h in the snakes cpp file. If you want it as a member variable for whatever reason you need to include board in snakes h...
by Yumtard
June 18th, 2018, 9:21 pm
Forum: Everything
Topic: Spawning Snek Obstacles
Replies: 6
Views: 2337

Re: Spawning Snek Obstacles

Firepath wrote:That's what I did, except I probably used a do - while loop.
I had completely forgotten about do-while loops :lol: Don't think I've used one for a year
by Yumtard
June 18th, 2018, 8:14 pm
Forum: Everything
Topic: Spawning Snek Obstacles
Replies: 6
Views: 2337

Re: Spawning Snek Obstacles

I guess you could do something like:

(pseudo code)

occupied = true;
vec2 location;
while (occupied)
{
location = random;
occupied = brd.GetIsOccupied(location);
}
by Yumtard
June 15th, 2018, 8:36 pm
Forum: Everything
Topic: I think this is complicated problem?
Replies: 12
Views: 4692

Re: I think this is complicated problem?

How about this? #include <iostream> int main() { const int max_primes = 500; int primes[max_primes]; bool is_prime; int count = 0, n = 1; while (count < max_primes) { n++; is_prime = true; for (int i = 0; i < count && is_prime; i++) if (n % primes[i] == 0) is_prime = false; if (is_prime) primes[coun...
by Yumtard
June 10th, 2018, 6:36 pm
Forum: Everything
Topic: Laziness
Replies: 9
Views: 3139

Re: Laziness

This is what I do

1. wake up early
2. Make daily checklists of what to do that day
3. every sunday I meal prep for the following week so I don't need to spend time/energy on making lunch
by Yumtard
June 9th, 2018, 9:55 am
Forum: Everything
Topic: Snek Obstacle
Replies: 2
Views: 1326

Re: Snek Obstacle

Yeah making a new one each time would work. You can do something like .h std::vector<Obstacle*> __obstacles; .cpp if (obstacleSpawnCounter > obstacleSpawnPeriod) { obstacleSpawnCounter = 0; _obstacles.emplace_back(new Obstacle(rng, brd, snek)); } //draw std::vector<Obstacle*>::iterator it = _obstacl...
by Yumtard
June 8th, 2018, 3:51 pm
Forum: Everything
Topic: Noob learns to code in 3 months
Replies: 670
Views: 198928

Re: Noob learns to code in 3 months

Yeah :D Starting to take shape now though. Think the only thing we're missing is emissive textures on the ps4
by Yumtard
June 5th, 2018, 8:15 pm
Forum: Everything
Topic: Noob learns to code in 3 months
Replies: 670
Views: 198928

Re: Noob learns to code in 3 months

Current state of ps4 port

https://i.imgur.com/Jxsl6Yv.png