Page 4 of 7

Re: Snake Game Tutorial 14a

Posted: March 19th, 2017, 7:59 am
by chili
Yea, in Snek I restrict the use of Location for positions on the game grid.

Later on in Memesweeper, I create a class Vei2 (2D integer vector type) and I use it for both position on screen and position on the game grid. When I do this, I try to make it clear in the variable name what the usage of the Vei2 is (screen or grid).

Re: Snake Game Tutorial 14a

Posted: March 19th, 2017, 5:40 pm
by Multibyte
Can't wait to start studying this. One of my favorite games from many years ago when games were really simple. :D

I used to beat all my friends. ;) You could play two players against each other, each controlling a snake - 2 snakes on the screen, sitting side by side and using different keys on the same keyboard. You'd not only try to collect objects but also try to trap the other guy's snake to kill him. Lots of fun times. :lol:

If I'm remembering right, the one I used to play was developed with Qbasic and was coming as part of the MS-DOS package.

Re: Snake Game Tutorial 14a

Posted: March 19th, 2017, 11:04 pm
by albinopapa
Multibyte wrote:Can't wait to start studying this. One of my favorite games from many years ago when games were really simple. :D

I used to beat all my friends. ;) You could play two players against each other, each controlling a snake - 2 snakes on the screen, sitting side by side and using different keys on the same keyboard. You'd not only try to collect objects but also try to trap the other guy's snake to kill him. Lots of fun times. :lol:

If I'm remembering right, the one I used to play was developed with Qbasic and was coming as part of the MS-DOS package.

NIBBLES, that was my first programming experience. I did the same thing making it 3 player so my two bros could play along.

Re: Snake Game Tutorial 14a

Posted: March 20th, 2017, 2:16 am
by Multibyte
albinopapa wrote:
Multibyte wrote:Can't wait to start studying this. One of my favorite games from many years ago when games were really simple. :D

I used to beat all my friends. ;) You could play two players against each other, each controlling a snake - 2 snakes on the screen, sitting side by side and using different keys on the same keyboard. You'd not only try to collect objects but also try to trap the other guy's snake to kill him. Lots of fun times. :lol:

If I'm remembering right, the one I used to play was developed with Qbasic and was coming as part of the MS-DOS package.

NIBBLES, that was my first programming experience. I did the same thing making it 3 player so my two bros could play along.
Yes, it was NIBBLES. I had forgotten the name. :)

Re: Snake Game Tutorial 14a

Posted: March 21st, 2017, 6:45 pm
by Zedtho
Just as a side note, why are we making a grid for the snake game? Why not finetune it?

Re: Snake Game Tutorial 14a

Posted: March 21st, 2017, 7:43 pm
by albinopapa
Zedtho wrote:Just as a side note, why are we making a grid for the snake game? Why not finetune it?

What do you mean fine tune it?

Re: Snake Game Tutorial 14a

Posted: March 22nd, 2017, 1:09 am
by chili
I imagine he means, why not allow the position of the snake to be more fine-grained. The main reasons are: 1) the original snake game is done on a relatively coarse-grained grid and 2) I wanted to introduce the ideas of grid-based games because it's a pattern that appears extremely frequently in games.

Re: Snake Game Tutorial 14a

Posted: March 22nd, 2017, 6:03 am
by Zedtho
Thanks!
Yeah I couldn't find the right word to describe what I meant, sorry

Re: Snake Game Tutorial 14a

Posted: April 13th, 2017, 11:29 am
by Adagio
Hey guys! New to this forum and programming in general.
I've just finished going through tutorial 14a and I tried writing the code up till that point but I'm unable to build the code successfully.
The constructor for snake::snake has an error that reads "the default constructor of "Snake::Segment" cannot be referenced -- it is a deleted function".
Why is the compiler referencing the default constructor of Snake::Segment to construct the snake::snake class?
I've tried replicating the code to be identical to the one shown in tutorial 14a and the error is still there.

Here's the output when i tried to build it:
1>------ Build started: Project: Engine, Configuration: Debug x64 ------
1>Snake.cpp
1>c:\users\Adagio\desktop\t14-snek-start\engine\snake.cpp(5): error C2280: 'Snake::Segment::Segment(void)': attempting to reference a deleted function
1>c:\users\Adagio\desktop\t14-snek-start\engine\snake.h(20): note: compiler has generated 'Snake::Segment::Segment' here
1>c:\users\Adagio\desktop\t14-snek-start\engine\snake.h(20): note: 'Snake::Segment::Segment(void)': function was implicitly deleted because a data member 'Snake::Segment::loc' has either no appropriate default constructor or overload resolution was ambiguous
1>c:\users\Adagio\desktop\t14-snek-start\engine\snake.h(18): note: see declaration of 'Snake::Segment::loc'
1>Done building project "Engine.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

What's the problem here?

Re: Snake Game Tutorial 14a

Posted: April 13th, 2017, 2:10 pm
by chili
You're missing the default constructor for the segment

You want like Segment() = default;