|
|
|
@ -3,37 +3,26 @@
|
|
|
|
|
#include <mario.h>
|
|
|
|
|
#include <world.h>
|
|
|
|
|
#include <base.h>
|
|
|
|
|
#include <keyboard.h>
|
|
|
|
|
|
|
|
|
|
static int y=0;
|
|
|
|
|
|
|
|
|
|
int cameraX() {return min(max(mario.p.x-40,0),map_current->w*8-128);}
|
|
|
|
|
int cameraY() {return max(y-32,0);}
|
|
|
|
|
|
|
|
|
|
static int immobile=0;
|
|
|
|
|
static int last_vy=0;
|
|
|
|
|
|
|
|
|
|
static int immobile=0;
|
|
|
|
|
static int distance=0;
|
|
|
|
|
static int delta_y=0; // the player can choose the y positionning of the camera with arrows
|
|
|
|
|
|
|
|
|
|
int cameraX() {return min(max(mario.p.x-40,0),map_current->w*8-128);}
|
|
|
|
|
int cameraY() {return max(max(y-32,0)-delta_y,0);}
|
|
|
|
|
|
|
|
|
|
void cameraMove() // movement vertical seulement
|
|
|
|
|
void cameraMove() // only vertical movement
|
|
|
|
|
{
|
|
|
|
|
/* static int isMoving=0;
|
|
|
|
|
static int ref_y=0;
|
|
|
|
|
if (mario.p.y-cameraY()<16 || mario.p.y-cameraY()>56)
|
|
|
|
|
{
|
|
|
|
|
isMoving=1;
|
|
|
|
|
ref_y=mario.p.y;
|
|
|
|
|
}
|
|
|
|
|
if (isMoving)
|
|
|
|
|
{
|
|
|
|
|
for (int i=0; i<9; i++)
|
|
|
|
|
y+=sgn(mario.p.y-y);
|
|
|
|
|
if (y==ref_y)
|
|
|
|
|
isMoving=0;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
if (MKB_getKeyState(MK_UP) && abs(delta_y)<24) delta_y-=4;
|
|
|
|
|
if (MKB_getKeyState(MK_DOWN) && abs(delta_y)<24) delta_y+=4;
|
|
|
|
|
if (!MKB_getKeyState(MK_DOWN) && !MKB_getKeyState(MK_UP)) delta_y-=4*sgn(delta_y);
|
|
|
|
|
|
|
|
|
|
static int camera_vy=0;
|
|
|
|
|
if (mario.p.y==last_vy) // mario arrêté
|
|
|
|
|
immobile++;
|
|
|
|
|
immobile++;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
last_vy=mario.p.y;
|
|
|
|
@ -54,13 +43,13 @@ void cameraMove() // movement vertical seulement
|
|
|
|
|
|
|
|
|
|
//décéleration après avoir parvouru la moitié de la distance, sinon acceleration
|
|
|
|
|
if (camera_vy*(camera_vy+1)>distance)
|
|
|
|
|
camera_vy--;
|
|
|
|
|
camera_vy--;
|
|
|
|
|
else
|
|
|
|
|
camera_vy++;
|
|
|
|
|
camera_vy++;
|
|
|
|
|
//y++;
|
|
|
|
|
|
|
|
|
|
if (camera_vy<0)
|
|
|
|
|
camera_vy=0;
|
|
|
|
|
camera_vy=0;
|
|
|
|
|
|
|
|
|
|
if (((y+camera_vy*sgn(mario.p.y-y)/2)-(mario.p.y))*sgn(mario.p.y-y)>0)
|
|
|
|
|
{
|
|
|
|
@ -68,7 +57,7 @@ void cameraMove() // movement vertical seulement
|
|
|
|
|
camera_vy=0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
y+=(camera_vy*sgn(mario.p.y-y))/2;
|
|
|
|
|
y+=(camera_vy*sgn(mario.p.y-y))/2;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
last_vy=mario.p.y;
|
|
|
|
|