Snake Game Tutorial 14a

The Partridge Family were neither partridges nor a family. Discuss.
User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Snake Game Tutorial 14a

Post by chili » March 19th, 2017, 7:59 am

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).
Chili

User avatar
Multibyte
Posts: 42
Joined: September 17th, 2013, 5:55 am
Location: USA

Re: Snake Game Tutorial 14a

Post by Multibyte » March 19th, 2017, 5:40 pm

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.

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Snake Game Tutorial 14a

Post by albinopapa » March 19th, 2017, 11:04 pm

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.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
Multibyte
Posts: 42
Joined: September 17th, 2013, 5:55 am
Location: USA

Re: Snake Game Tutorial 14a

Post by Multibyte » March 20th, 2017, 2:16 am

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. :)

User avatar
Zedtho
Posts: 189
Joined: February 14th, 2017, 7:32 pm

Re: Snake Game Tutorial 14a

Post by Zedtho » March 21st, 2017, 6:45 pm

Just as a side note, why are we making a grid for the snake game? Why not finetune it?

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Snake Game Tutorial 14a

Post by albinopapa » March 21st, 2017, 7:43 pm

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?
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Snake Game Tutorial 14a

Post by chili » March 22nd, 2017, 1:09 am

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.
Chili

User avatar
Zedtho
Posts: 189
Joined: February 14th, 2017, 7:32 pm

Re: Snake Game Tutorial 14a

Post by Zedtho » March 22nd, 2017, 6:03 am

Thanks!
Yeah I couldn't find the right word to describe what I meant, sorry

Adagio
Posts: 5
Joined: April 13th, 2017, 11:07 am

Re: Snake Game Tutorial 14a

Post by Adagio » April 13th, 2017, 11:29 am

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?

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Snake Game Tutorial 14a

Post by chili » April 13th, 2017, 2:10 pm

You're missing the default constructor for the segment

You want like Segment() = default;
Chili

Post Reply