# Game issues for christmas

**URL:** <https://discourse.processing.org/t/game-issues-for-christmas/14780>\
**Category:** Coding Questions\
**Created:** [October 18, 2019, 3:30pm UTC](https://discourse.processing.org/t/game-issues-for-christmas/14780 "2019-10-18T15:30:40Z")\
**Posts on this page:** 1\
**Showing post:** 57

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [October 20, 2019, 9:01pm UTC](https://discourse.processing.org/t/game-issues-for-christmas/14780/57 "2019-10-20T21:01:35Z")

</div>

In my opinion you could rewrite your mousePressed like this:

```auto

function mousePressed() {

  if (state==0) {
    mousePressedForState0();
  }
  //----
  else if (state==1) {
    mousePressedForState1();
  }
  //----
  else if (state==2) {
    mousePressedForState2();
  }
  //----
  else if (state==3) {
    mousePressedForState3();
  }
  //----
  else if (state==4) {
    mousePressedForState4();
  }
  //----
  else if (state==5) {
    mousePressedForState5();
  } else {
    // error
    println ("Error"); 
    exit(); 
    return;
  }//else 
  //
}//function

```

Then make those functions and put what you have in mousePressed now inside those functions (the stuff for state 0 in the appropriate function mousePressedForState0() and so on).

Then your code is better readable since it’s in nice modules.

Same goes for function draw() by the way

---

_[View the full topic](https://discourse.processing.org/t/game-issues-for-christmas/14780)._
