Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

bug fixed

  • Loading branch information...
commit a69b3fdbfd7685869940c1039c13734b42ce6418 1 parent 03c54da
thebluber authored April 11, 2012

Showing 2 changed files with 19 additions and 9 deletions. Show diff stats Hide diff stats

  1. BIN  Main.swf
  2. 28  Snake.as
BIN  Main.swf
Binary file not shown
28  Snake.as
@@ -96,19 +96,29 @@ package {
96 96
 
97 97
       var xSpeed:int = 0;
98 98
       var ySpeed:int = 0;
99  
-
  99
+      
100 100
       switch(_head.facing) {
101 101
         case FlxObject.RIGHT:
102  
-          xSpeed = 16;
  102
+          if (_head.facing !== FlxObject.LEFT) {
  103
+            xSpeed = 16;
  104
+          } else {
  105
+  
  106
+          }
103 107
           break;
104 108
         case FlxObject.LEFT:
105  
-          xSpeed = -16;
  109
+          if (_head.facing !== FlxObject.RIGHT) {
  110
+            xSpeed = -16;
  111
+          };
106 112
           break;
107 113
         case FlxObject.UP:
108  
-          ySpeed = -16;
  114
+          if (_head.facing !== FlxObject.DOWN) {
  115
+            ySpeed = -16;
  116
+          };
109 117
           break;
110 118
         case FlxObject.DOWN:
111  
-          ySpeed = 16;
  119
+          if (_head.facing !== FlxObject.UP) {
  120
+            ySpeed = 16;
  121
+          };
112 122
           break;
113 123
       }
114 124
 
@@ -124,16 +134,16 @@ package {
124 134
     override public function update():void {
125 135
       super.update();
126 136
 
127  
-      if(FlxG.keys.UP){
  137
+      if(FlxG.keys.UP && _head.facing != FlxObject.DOWN){
128 138
         _head.facing = FlxObject.UP;
129 139
       } else
130  
-      if(FlxG.keys.DOWN){
  140
+      if(FlxG.keys.DOWN && _head.facing != FlxObject.UP){
131 141
         _head.facing = FlxObject.DOWN;
132 142
       } else 
133  
-      if(FlxG.keys.RIGHT){
  143
+      if(FlxG.keys.RIGHT && _head.facing != FlxObject.LEFT){
134 144
         _head.facing = FlxObject.RIGHT;
135 145
       } else 
136  
-      if(FlxG.keys.LEFT){
  146
+      if(FlxG.keys.LEFT && _head.facing != FlxObject.RIGHT){
137 147
         _head.facing = FlxObject.LEFT;
138 148
       } 
139 149
 

0 notes on commit a69b3fd

Please sign in to comment.
Something went wrong with that request. Please try again.