Skip to content

Module #1 (Tahsina Bintay Azam)#15

Open
tahsina-azam wants to merge 3 commits intorecruit-org:module-1from
tahsina-azam:module-1
Open

Module #1 (Tahsina Bintay Azam)#15
tahsina-azam wants to merge 3 commits intorecruit-org:module-1from
tahsina-azam:module-1

Conversation

@tahsina-azam
Copy link
Copy Markdown

No description provided.

pages/index.js Outdated

var dumX=head.x + direction.x;
var dumY=head.y + direction.y;
if(head.x + direction.x>24){
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

head.x + direction.x is dumX right?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes :)

@royantar0311
Copy link
Copy Markdown

for multiple foods, you could use an array of foods instead of 4 food states. creating more states is redundant and also hard to manage, you know how hard it is to manage those 4 foods.
4 different food types though they have the same behavior, 4 different isFood method though they have the same functionality!

Copy link
Copy Markdown
Contributor

@Corei13 Corei13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do a refactor so you use an array of food, instead of four separate food objects. That will simplify the code a lot!

Use my video or other PRs as reference, and ask in the channel if there's any questions.

@tahsina-azam
Copy link
Copy Markdown
Author

Let's do a refactor so you use an array of food, instead of four separate food objects. That will simplify the code a lot!

Use my video or other PRs as reference, and ask in the channel if there are any questions.

okay, I will use an array of food using your video as a reference, actually, I wanted to use an array, But I was unable to create one so I opted for four different foods. I thought when it would be the time for the fourth food to appear it would also be the time for the first food to disappear if I put four foods in a loop with 3-sec interval, and in case of any food getting eaten by the snake in the meantime, I just relocated it out of the grid as it would again appear when its turn will come. But it also didn't work properly :")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants