projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
- beginnings of a wingling
[supertux.git]
/
src
/
gameobjs.cpp
diff --git
a/src/gameobjs.cpp
b/src/gameobjs.cpp
index
61580e2
..
743d9cb
100644
(file)
--- a/
src/gameobjs.cpp
+++ b/
src/gameobjs.cpp
@@
-47,7
+47,7
@@
BouncyDistro::action(float elapsed_time)
}
void
}
void
-BouncyDistro::draw(
ViewPort
& viewport, int )
+BouncyDistro::draw(
Camera
& viewport, int )
{
img_distro[0]->draw(viewport.world2screen(position));
}
{
img_distro[0]->draw(viewport.world2screen(position));
}
@@
-71,7
+71,7
@@
BrokenBrick::action(float elapsed_time)
}
void
}
void
-BrokenBrick::draw(
ViewPort
& viewport, int )
+BrokenBrick::draw(
Camera
& viewport, int )
{
SDL_Rect src, dest;
src.x = rand() % 16;
{
SDL_Rect src, dest;
src.x = rand() % 16;
@@
-110,7
+110,7
@@
BouncyBrick::action(float elapsed_time)
}
void
}
void
-BouncyBrick::draw(
ViewPort
& viewport, int)
+BouncyBrick::draw(
Camera
& viewport, int)
{
Tile::draw(viewport.world2screen(position + Vector(0, offset)), shape);
}
{
Tile::draw(viewport.world2screen(position + Vector(0, offset)), shape);
}
@@
-135,7
+135,7
@@
FloatingScore::action(float elapsed_time)
}
void
}
void
-FloatingScore::draw(
ViewPort
& viewport, int )
+FloatingScore::draw(
Camera
& viewport, int )
{
gold_text->draw(str, viewport.world2screen(position));
}
{
gold_text->draw(str, viewport.world2screen(position));
}
@@
-174,7
+174,7
@@
Trampoline::write(LispWriter& writer)
}
void
}
void
-Trampoline::draw(
ViewPort
& viewport, int )
+Trampoline::draw(
Camera
& viewport, int )
{
img_trampoline[frame]->draw(viewport.world2screen(Vector(base.x, base.y)));
frame = 0;
{
img_trampoline[frame]->draw(viewport.world2screen(Vector(base.x, base.y)));
frame = 0;
@@
-264,8
+264,10
@@
Trampoline::collision(void *p_c_object, int c_object, CollisionType type)
else
frame = 0;
else
frame = 0;
- if (squish_amount < 20)
+ if (squish_amount < 20)
{
pplayer_c->physic.set_velocity_y(power);
pplayer_c->physic.set_velocity_y(power);
+ pplayer_c->fall_mode = Player::TRAMPOLINE_JUMP;
+ }
else if (pplayer_c->physic.get_velocity_y() < 0)
pplayer_c->physic.set_velocity_y(-squish_amount/32);
}
else if (pplayer_c->physic.get_velocity_y() < 0)
pplayer_c->physic.set_velocity_y(-squish_amount/32);
}
@@
-280,8
+282,7
@@
Trampoline::collision(void *p_c_object, int c_object, CollisionType type)
/* Flying Platform */
/* Flying Platform */
-#define FLYING_PLATFORM_FRAMES 1
-Sprite *img_flying_platform[FLYING_PLATFORM_FRAMES];
+Sprite *img_flying_platform;
FlyingPlatform::FlyingPlatform(DisplayManager& displaymanager, LispReader& reader)
{
FlyingPlatform::FlyingPlatform(DisplayManager& displaymanager, LispReader& reader)
{
@@
-317,9
+318,9
@@
FlyingPlatform::write(LispWriter& writer)
}
void
}
void
-FlyingPlatform::draw(
ViewPort
& viewport, int )
+FlyingPlatform::draw(
Camera
& viewport, int )
{
{
-img_flying_platform
[frame]
->draw(viewport.world2screen(Vector(base.x, base.y)));
+img_flying_platform->draw(viewport.world2screen(Vector(base.x, base.y)));
}
void
}
void
@@
-327,21
+328,21
@@
FlyingPlatform::action(float frame_ratio)
{
// TODO: Remove if we're too far off the screen
{
// TODO: Remove if we're too far off the screen
- // FIXME: change frame
if(!move)
return;
if((unsigned)point+1 != pos_x.size())
if(!move)
return;
if((unsigned)point+1 != pos_x.size())
+ {
if(((pos_x[point+1] > pos_x[point] && base.x >= pos_x[point+1]) ||
(pos_x[point+1] < pos_x[point] && base.x <= pos_x[point+1]) ||
if(((pos_x[point+1] > pos_x[point] && base.x >= pos_x[point+1]) ||
(pos_x[point+1] < pos_x[point] && base.x <= pos_x[point+1]) ||
- pos_x[point
+1
] == pos_x[point+1]) &&
+ pos_x[point] == pos_x[point+1]) &&
((pos_y[point+1] > pos_y[point] && base.y >= pos_y[point+1]) ||
(pos_y[point+1] < pos_y[point] && base.y <= pos_y[point+1]) ||
((pos_y[point+1] > pos_y[point] && base.y >= pos_y[point+1]) ||
(pos_y[point+1] < pos_y[point] && base.y <= pos_y[point+1]) ||
- pos_y[point
+1
] == pos_y[point+1]))
+ pos_y[point] == pos_y[point+1]))
{
point++;
{
point++;
-std::cerr << "next point: " << point << std::endl;
}
}
+ }
else // last point
{
// point = 0;
else // last point
{
// point = 0;
@@
-349,14
+350,14
@@
else // last point
return;
}
return;
}
-if(pos_x[point] > base.x)
+if(pos_x[point
+1
] > base.x)
base.x += velocity * frame_ratio;
base.x += velocity * frame_ratio;
-else if(pos_x[point] < base.x)
+else if(pos_x[point
+1
] < base.x)
base.x -= velocity * frame_ratio;
base.x -= velocity * frame_ratio;
-if(pos_y[point] > base.y)
+if(pos_y[point
+1
] > base.y)
base.y += velocity * frame_ratio;
base.y += velocity * frame_ratio;
-else if(pos_y[point] < base.y)
+else if(pos_y[point
+1
] < base.y)
base.y -= velocity * frame_ratio;
/*
float x = pos_x[point+1] - pos_x[point];
base.y -= velocity * frame_ratio;
/*
float x = pos_x[point+1] - pos_x[point];
@@
-387,7
+388,7
@@
FlyingPlatform::collision(void *p_c_object, int c_object, CollisionType type)
case CO_PLAYER:
// pplayer_c = (Player*) p_c_object;
move = true;
case CO_PLAYER:
// pplayer_c = (Player*) p_c_object;
move = true;
-
+
break;
default:
break;
default:
@@
-406,9
+407,5
@@
void load_object_gfx()
img_trampoline[i] = sprite_manager->load(sprite_name);
}
img_trampoline[i] = sprite_manager->load(sprite_name);
}
- for (int i = 0; i < FLYING_PLATFORM_FRAMES; i++)
- {
- sprintf(sprite_name, "flying_platform-%i", i+1);
- img_flying_platform[i] = sprite_manager->load(sprite_name);
- }
+ img_flying_platform = sprite_manager->load("flying_platform");
}
}