Advertisement
Weegee

Untitled

Aug 15th, 2011
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. So, I've found a solution. And it **was** a stupid mistake I've made ... really stupid :D
  2.  
  3. The playing field is declared by `int field[FIELDMAXX][FIELDMAXY];`, where `FIELDMAXX` is 78 and `FIELDMAXY` is 21. Now have a look at `create_obstacle()`: The coordinates for newly created obstacles are `FIELDMAXX + 1` and `get_randypos()` (which returns an integer from 1 to 21). And here it comes, the typical beginner's mistake: In `move_obstacle()`, there's a line which says `field[target_ob->x_pos][target_ob->y_pos] = OBSTACLE;` (OBSTACLE is defined as 2).
  4.  
  5. Every obstacle moves every second one "unit of length" to the left (`target_ob->x_pos--;`). So, if a newly created obstacle with `x_pos = 79` (which is `FIELDMAXX + 1`) and `y_pos = 21` is moved by `move_obstacle()`, its new `x_pos` is **78** (while its `y_pos` is **21**). And as a consequence, the line I've mentioned above tries to set `field[78][21]` to `OBSTACLE` - and this is impossible (out of bounds). I feel a bit ashamed of myself now :)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement