#include "tile.h"
#include "screen.h"
-texture_type tux_life;
-std::vector<texture_type> tux_right;
-std::vector<texture_type> tux_left;
-texture_type smalltux_jump_left;
-texture_type smalltux_jump_right;
-texture_type smalltux_stand_left;
-texture_type smalltux_stand_right;
-
-texture_type bigtux_right[3];
-texture_type bigtux_left[3];
-texture_type bigtux_right_jump;
-texture_type bigtux_left_jump;
-texture_type ducktux_right;
-texture_type ducktux_left;
-texture_type skidtux_right;
-texture_type skidtux_left;
-texture_type firetux_right[3];
-texture_type firetux_left[3];
-texture_type bigfiretux_right[3];
-texture_type bigfiretux_left[3];
-texture_type bigfiretux_right_jump;
-texture_type bigfiretux_left_jump;
-texture_type duckfiretux_right;
-texture_type duckfiretux_left;
-texture_type skidfiretux_right;
-texture_type skidfiretux_left;
-texture_type cape_right[2];
-texture_type cape_left[2];
-texture_type bigcape_right[2];
-texture_type bigcape_left[2];
+Surface* tux_life;
+std::vector<Surface*> tux_right;
+std::vector<Surface*> tux_left;
+Surface* smalltux_jump_left;
+Surface* smalltux_jump_right;
+Surface* smalltux_stand_left;
+Surface* smalltux_stand_right;
+
+Surface* bigtux_right[3];
+Surface* bigtux_left[3];
+Surface* bigtux_right_jump;
+Surface* bigtux_left_jump;
+Surface* ducktux_right;
+Surface* ducktux_left;
+Surface* skidtux_right;
+Surface* skidtux_left;
+Surface* firetux_right[3];
+Surface* firetux_left[3];
+Surface* bigfiretux_right[3];
+Surface* bigfiretux_left[3];
+Surface* bigfiretux_right_jump;
+Surface* bigfiretux_left_jump;
+Surface* duckfiretux_right;
+Surface* duckfiretux_left;
+Surface* skidfiretux_right;
+Surface* skidfiretux_left;
+Surface* cape_right[2];
+Surface* cape_left[2];
+Surface* bigcape_right[2];
+Surface* bigcape_left[2];
void player_input_init(player_input_type* pplayer_input)
{
/* Move tux: */
previous_base = base;
- duck = false;
physic.apply(frame_ratio, base.x, base.y);
if(dying == DYING_NOT) {
player_status.next_level = 1;
}
- /* Duck! */
- if (input.down == DOWN && size == BIG && !duck)
- {
- duck = true;
- base.height = 32;
- base.y += 32;
- // changing base size confuses collision otherwise
- old_base = previous_base = base;
- }
- else if(input.down == UP && size == BIG && duck)
- {
- duck = false;
- base.y -= 32;
- base.height = 64;
- old_base = previous_base = base;
- }
-
// check some timers
skidding_timer.check();
invincible_timer.check();
ax = WALK_ACCELERATION_X * -1.5;
}
}
-
+
+ // if we're on ice slow down acceleration or deceleration
+ if (isice(base.x, base.y + base.height))
+ {
+ /* the acceleration/deceleration rate on ice is inversely proportional to
+ * the current velocity.
+ */
+
+ // increasing 1 will increase acceleration/deceleration rate
+ // decreasing 1 will decrease acceleration/deceleration rate
+ // must stay above zero, though
+ if (ax != 0) ax *= 1 / fabs(vx);
+ }
+
physic.set_velocity(vx, vy);
physic.set_acceleration(ax, ay);
}
if (dir == RIGHT)
{
- texture_draw(&cape_right[global_frame_counter % 2],
- base.x- scroll_x, base.y);
+ cape_right[global_frame_counter % 2]->draw(base.x- scroll_x, base.y);
}
else
{
- texture_draw(&cape_left[global_frame_counter % 2],
+ cape_left[global_frame_counter % 2]->draw(
base.x- scroll_x, base.y);
}
}
if (physic.get_velocity_y() != 0)
{
if (dir == RIGHT)
- texture_draw(&smalltux_jump_right, base.x - scroll_x, base.y - 10);
+ smalltux_jump_right->draw( base.x - scroll_x, base.y - 10);
else
- texture_draw(&smalltux_jump_left, base.x - scroll_x, base.y - 10);
+ smalltux_jump_left->draw( base.x - scroll_x, base.y - 10);
}
else
{
if (fabsf(physic.get_velocity_x()) < 1.0f) // standing
{
if (dir == RIGHT)
- texture_draw(&smalltux_stand_right, base.x - scroll_x, base.y - 9);
+ smalltux_stand_right->draw( base.x - scroll_x, base.y - 9);
else
- texture_draw(&smalltux_stand_left, base.x - scroll_x, base.y - 9);
+ smalltux_stand_left->draw( base.x - scroll_x, base.y - 9);
}
else // moving
{
if (dir == RIGHT)
- texture_draw(&tux_right[(global_frame_counter/2) % tux_right.size()],
+ tux_right[(global_frame_counter/2) % tux_right.size()]->draw(
base.x - scroll_x, base.y - 9);
else
- texture_draw(&tux_left[(global_frame_counter/2) % tux_left.size()],
+ tux_left[(global_frame_counter/2) % tux_left.size()]->draw(
base.x - scroll_x, base.y - 9);
}
}
if (dir == RIGHT)
{
- texture_draw(&firetux_right[frame_], base.x- scroll_x, base.y);
+ firetux_right[frame_]->draw( base.x- scroll_x, base.y);
}
else
{
- texture_draw(&firetux_left[frame_], base.x- scroll_x, base.y);
+ firetux_left[frame_]->draw( base.x- scroll_x, base.y);
}
}
}
{
if (invincible_timer.started())
{
- float capex = base.x + (base.width - bigcape_right[0].w) / 2;
+ float capex = base.x + (base.width - bigcape_right[0]->w) / 2;
capex -= scroll_x;
- float capey = base.y + (base.height - bigcape_right[0].h) / 2;
+ float capey = base.y + (base.height - bigcape_right[0]->h) / 2;
/* Draw cape (just not in ducked mode since that looks silly): */
if (dir == RIGHT)
{
- texture_draw(&bigcape_right[global_frame_counter % 2],
+ bigcape_right[global_frame_counter % 2]->draw(
capex, capey);
}
else
{
- texture_draw(&bigcape_left[global_frame_counter % 2],
+ bigcape_left[global_frame_counter % 2]->draw(
capex, capey);
}
}
{
if (dir == RIGHT)
{
- texture_draw(&bigtux_right[frame_],
+ bigtux_right[frame_]->draw(
base.x- scroll_x - 8, base.y);
}
else
{
- texture_draw(&bigtux_left[frame_],
+ bigtux_left[frame_]->draw(
base.x- scroll_x - 8, base.y);
}
}
{
if (dir == RIGHT)
{
- texture_draw(&bigtux_right_jump,
+ bigtux_right_jump->draw(
base.x- scroll_x - 8, base.y);
}
else
{
- texture_draw(&bigtux_left_jump,
+ bigtux_left_jump->draw(
base.x- scroll_x - 8, base.y);
}
}
{
if (dir == RIGHT)
{
- texture_draw(&skidtux_right,
+ skidtux_right->draw(
base.x- scroll_x - 8, base.y);
}
else
{
- texture_draw(&skidtux_left,
+ skidtux_left->draw(
base.x- scroll_x - 8, base.y);
}
}
{
if (dir == RIGHT)
{
- texture_draw(&ducktux_right, base.x- scroll_x - 8, base.y - 16);
+ ducktux_right->draw( base.x- scroll_x - 8, base.y - 16);
}
else
{
- texture_draw(&ducktux_left, base.x- scroll_x - 8, base.y - 16);
+ ducktux_left->draw( base.x- scroll_x - 8, base.y - 16);
}
}
}
{
if (dir == RIGHT)
{
- texture_draw(&bigfiretux_right[frame_],
+ bigfiretux_right[frame_]->draw(
base.x- scroll_x - 8, base.y);
}
else
{
- texture_draw(&bigfiretux_left[frame_],
+ bigfiretux_left[frame_]->draw(
base.x- scroll_x - 8, base.y);
}
}
{
if (dir == RIGHT)
{
- texture_draw(&bigfiretux_right_jump,
+ bigfiretux_right_jump->draw(
base.x- scroll_x - 8, base.y);
}
else
{
- texture_draw(&bigfiretux_left_jump,
+ bigfiretux_left_jump->draw(
base.x- scroll_x - 8, base.y);
}
}
{
if (dir == RIGHT)
{
- texture_draw(&skidfiretux_right,
+ skidfiretux_right->draw(
base.x- scroll_x - 8, base.y);
}
else
{
- texture_draw(&skidfiretux_left,
+ skidfiretux_left->draw(
base.x- scroll_x - 8, base.y);
}
}
{
if (dir == RIGHT)
{
- texture_draw(&duckfiretux_right, base.x- scroll_x - 8, base.y - 16);
+ duckfiretux_right->draw( base.x- scroll_x - 8, base.y - 16);
}
else
{
- texture_draw(&duckfiretux_left, base.x- scroll_x - 8, base.y - 16);
+ duckfiretux_left->draw( base.x- scroll_x - 8, base.y - 16);
}
}
}
}
if(dying)
- text_drawf(&gold_text,"Penguins can fly !:",0,0,A_HMIDDLE,A_VMIDDLE,1);
+ gold_text->drawf("Penguins can fly !:",0,0,A_HMIDDLE,A_VMIDDLE,1);
if (debug_mode)
fillrect(base.x - scroll_x, base.y, 32, 32, 75,75,75, 150);