snake no longer turns back on itself
This commit is contained in:
		
							parent
							
								
									68c2ae2498
								
							
						
					
					
						commit
						31b2f2c06d
					
				
					 3 changed files with 17 additions and 5 deletions
				
			
		
							
								
								
									
										
											BIN
										
									
								
								nsnake
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								nsnake
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								obj/main.o
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								obj/main.o
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										20
									
								
								src/main.c
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								src/main.c
									
									
									
									
									
								
							| 
						 | 
					@ -58,10 +58,22 @@ int main(void) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        field_print(f);
 | 
					        field_print(f);
 | 
				
			||||||
        switch (c) {
 | 
					        switch (c) {
 | 
				
			||||||
            case    up_key: dirn = UP;    break;
 | 
					            case up_key:
 | 
				
			||||||
            case  down_key: dirn = DOWN;  break;
 | 
					                if (dirn != DOWN)
 | 
				
			||||||
            case right_key: dirn = RIGHT; break;
 | 
					                    dirn = UP;
 | 
				
			||||||
            case  left_key: dirn = LEFT;  break;
 | 
					            break;
 | 
				
			||||||
 | 
					            case down_key:
 | 
				
			||||||
 | 
					                if (dirn != UP)
 | 
				
			||||||
 | 
					                    dirn = DOWN;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					            case right_key:
 | 
				
			||||||
 | 
					                if (dirn != LEFT)
 | 
				
			||||||
 | 
					                    dirn = RIGHT;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					            case left_key:
 | 
				
			||||||
 | 
					                if (dirn != RIGHT)
 | 
				
			||||||
 | 
					                    dirn = LEFT;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
            case quit_key: goto quit;
 | 
					            case quit_key: goto quit;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        snake_forward(s, dirn);
 | 
					        snake_forward(s, dirn);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue