- if (pict == 0)
- texture_draw_part(&bkg_title, 560, 270, 560, 270, 80, 75);
- else if (pict == 1)
- texture_draw(&anim1, 560, 270);
- else if (pict == 2)
- texture_draw(&anim2, 560, 270);
+ global_frame_counter++;
+ tux->key_event(SDLK_RIGHT,DOWN);
+
+ if(random_timer.check())
+ {
+ if(walking)
+ tux->key_event(SDLK_UP,UP);
+ else
+ tux->key_event(SDLK_UP,DOWN);
+ }
+ else
+ {
+ random_timer.start(rand() % 3000 + 3000);
+ walking = !walking;
+ }
+
+ // Wrap around at the end of the level back to the beginnig
+ if(plevel->width * 32 - 320 < tux->base.x)
+ {
+ tux->base.x = tux->base.x - (plevel->width * 32 - 640);
+ scroll_x = tux->base.x - 320;
+ }
+
+
+
+ float last_tux_x_pos = tux->base.x;
+ tux->action(frame_ratio);
+
+ // Jump if tux stays in the same position for one loop, ie. if he is
+ // stuck behind a wall
+ if (last_tux_x_pos == tux->base.x)
+ walking = false;
+
+ tux->draw();
+
+ /* DEMO end */