Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6761397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:11:08+00:00 2026-05-26T14:11:08+00:00

I am creating a snake game in C#/XNA for fun but it’s a good

  • 0

I am creating a snake game in C#/XNA for fun but it’s a good opportunity to practice some good object design.

Snake Object

There’s a snake object which is essentially a linked list, each node being a vector with X & Y co-ordinates which relate to the map.

Also a few properties such as whether the snake has just eaten (in which case, the last body node is not removed for this update), direction that the snake is moving in etc.

Map Object

The map (game area) holds its contents inside 2D array of integers – using an array of primitives to store the map should keep down memory consumption and be quicker (and easier) to iterate over than an array of vectors.

Contents are defined inside an enum {Empty, Wall, Snake, Food} which are then stored inside the array at the relevant co-ordinates.

A reference is also kept to the snake object within the map so that every call to render, loops through the nodes that make up the snake and render it into the correct position on the map.

Question!!

My question is… is this coupling too tight, in which case are there any suggestions (i.e. observer pattern) or is it okay for this situation…

I’ve tried to think of a way to decouple the snake from needing to know the co-ordinate system being used by the map, but can’t think of a way to make it work and keep the positions each nodes relative to each-other.

Any answers appreciated, cheers!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:11:09+00:00Added an answer on May 26, 2026 at 2:11 pm

    “is this coupling too tight?” No, it isn’t.

    In this case, the code required to decouple it is bigger, more complicated, and harder to maintain than the code required to simply implement it with the coupling.

    Furthermore, there is always going to be some level of coupling required. Coupling to “a coordinate system” is usually one of them in game development. You could, in fact, rigorously decouple your map and snake objects (again, not worth the effort), but they still need to share a common coordinate system in order to communicate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Creating a simple RPG game, first time using XNA. Trying to get my character
Greetings! I'm creating a simple snake game. I want to expand my classes in
I'm creating a WCF service which exposes an object graph which is expected to
I'm having some trouble figuring out the best/Djangoic way to do this. I'm creating
I'm trying to make a basic snake game in C++, I made a basic
I am creating a webpage which needs to pull in a Javascript library which
Is there a way to creating an observable from a sequence in F#? The
What is a (free) technology which requires the least amount of code for creating
I'm creating a form where people can enter a code, for example H23J3PW, which
I'm creating a survey in which users can upload about 6 pictures. What would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.