Changeset 1205


Ignore:
Timestamp:
Apr 8, 2012, 3:28:29 PM (8 years ago)
Author:
sam
Message:

mrpigeon: split the large project into game/player/enemy for now.

Location:
trunk/mrpigeon
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/mrpigeon/Makefile.am

    r1185 r1205  
    22noinst_PROGRAMS = mrpigeon
    33
    4 mrpigeon_SOURCES = mrpigeon.cpp mrpigeon.h
     4mrpigeon_SOURCES = \
     5    mrpigeon.cpp mrpigeon.h \
     6    player.cpp player.h \
     7    enemy.cpp enemy.h
    58mrpigeon_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@
    69mrpigeon_LDADD =
  • trunk/mrpigeon/mrpigeon.cpp

    r1202 r1205  
    2020
    2121#include "mrpigeon.h"
     22#include "player.h"
     23#include "enemy.h"
    2224
    23 MrPigeon::MrPigeon()
     25MrPigeon::MrPigeon() :
     26    totaltime(0.0f),
     27    railtime(0.0f),
     28    backtime(0.0f),
     29    speed(1.0f)
    2430{
     31    player = new Player(this);
     32    Ticker::Ref(player);
     33    enemy = new Enemy(this);
     34    Ticker::Ref(enemy);
     35
    2536    hud_progress = Tiler::Register("mrpigeon/gfx/HUD_timeline.png", ivec2(160,16), ivec2(0));
    2637    hud_arrow = Tiler::Register("mrpigeon/gfx/HUD_timelineArrow.png", ivec2(16,16), ivec2(0));
     
    3243    deco_floorrails = Tiler::Register("mrpigeon/gfx/DECO_floorRails3x.png", ivec2(72,24), ivec2(0));
    3344
    34     enemy_casualblue = Tiler::Register("mrpigeon/gfx/enemy_CasualBLUE_walk.png", ivec2(16,24), ivec2(0)); /* 6 frames */
    35     enemy_casualblueattack = Tiler::Register("mrpigeon/gfx/enemy_CasualBLUE_walkAttack.png", ivec2(16,24), ivec2(0)); /* 6 frames */
    36 
    37     pigeon_flying = Tiler::Register("mrpigeon/gfx/pigeon_flying.png", ivec2(16,16), ivec2(0)); /* 2 frames */
    38 
    39     player_dashdown = Tiler::Register("mrpigeon/gfx/player_DashDown.png", ivec2(16,32), ivec2(0));
    40     player_death = Tiler::Register("mrpigeon/gfx/player_Fall.png", ivec2(16,32), ivec2(0));
    41     player_fall = Tiler::Register("mrpigeon/gfx/player_Jump.png", ivec2(16,32), ivec2(0));
    42     player_jump = Tiler::Register("mrpigeon/gfx/player_kickAir.png", ivec2(16,32), ivec2(0)); /* 3 frames */
    43     player_kickair = Tiler::Register("mrpigeon/gfx/player_kickFloor.png", ivec2(16,32), ivec2(0)); /* 6 frames */
    44     player_kickfloor = Tiler::Register("mrpigeon/gfx/player_WalkB.png", ivec2(16,32), ivec2(0)); /* 8 frames */
    45     player_walkb = Tiler::Register("mrpigeon/gfx/player_Walk.png", ivec2(16,32), ivec2(0)); /* 8 frames */
    46     player_walk = Tiler::Register("mrpigeon/gfx/player_WalkRaiseFist.png", ivec2(16,32), ivec2(0)); /* 8 frames */
    47     player_walkraisefist = Tiler::Register("mrpigeon/gfx/player_Death.png", ivec2(16,32), ivec2(0)); /* 7 frames */
    48 
    49     totaltime = 0.0f;
    50     walktime = 0.0f;
    51     flytime = 0.0f;
    52     enemytime = 0.0f;
    53     railtime = 0.0f;
    54     backtime = 0.0f;
     45    position = vec3(0, 0, 0);
     46    bbox[0] = position;
     47    bbox[1] = vec3(512, 384, 0);
     48    Input::TrackMouse(this);
    5549}
    5650
     
    6155    totaltime += deltams;
    6256
    63     flytime += deltams;
    64     if (flytime > 400.0f)
    65         flytime -= 400.0f;
     57    if (totaltime > 100000.0f)
     58    {
     59        speed = 1.8f;
     60        active_deco = deco_citybackpav;
     61        active_deco_width = 192;
     62    }
     63    else if (totaltime > 49000.0f)
     64    {
     65        speed = 1.5f;
     66        active_deco = deco_citybackdefense;
     67        active_deco_width = 288;
     68    }
     69    else if (totaltime > 18000.0f)
     70    {
     71        speed = 1.2f;
     72        active_deco = deco_cityback;
     73        active_deco_width = 96;
     74    }
     75    else
     76    {
     77        speed = 1.0f;
     78        active_deco = deco_campagneback;
     79        active_deco_width = 144;
     80    }
    6681
    67     walktime += deltams;
    68     if (walktime > 700.0f)
    69         walktime -= 700.0f;
     82    deltams *= GetSpeed();
    7083
    71     railtime += deltams;
    72     if (railtime > 1000.0f)
    73         railtime -= 1000.0f;
     84    railtime = fmod(deltams + railtime, 1000.0f);;
     85    backtime = fmod(deltams + backtime, 10000.0f / 288 * active_deco_width);;
    7486
    75     backtime += deltams;
    76     if (backtime > 5000.0f)
    77         backtime -= 5000.0f;
     87    ivec3 buttons = Input::GetMouseButtons();
     88    if (buttons[0] || buttons[1])
     89    {
     90        if (!action)
     91            player->Action();
     92        action = 1;
     93    }
     94    else
     95        action = 0;
    7896
    79     enemytime += deltams;
    80     if (enemytime > 700.0f)
    81         enemytime -= 700.0f;
     97    if (buttons[2])
     98        Ticker::Shutdown();
    8299}
    83100
     
    95112    Scene::GetDefault()->AddTile(hud_arrow, 0, ivec3(48 + n, 18, 10), 0, vec2(3.0f));
    96113
    97     for (int i = -(int)(backtime * 144 / 5000.0f); i < 512 + 144; i += 144)
    98         Scene::GetDefault()->AddTile(deco_campagneback, 0, ivec3(i, 288, 0), 0, vec2(1.0f));
    99     //for (int i = -(int)(backtime * 96 / 5000.0f); i < 512 + 96; i += 96)
    100     //    Scene::GetDefault()->AddTile(deco_cityback, 0, ivec3(i, 288, 0), 0, vec2(1.0f));
    101     //for (int i = -(int)(backtime * 288 / 5000.0f); i < 512 + 288; i += 288)
    102     //    Scene::GetDefault()->AddTile(deco_citybackdefense, 0, ivec3(i, 288, 0), 0, vec2(1.0f));
    103     //for (int i = -(int)(backtime * 192 / 5000.0f); i < 512 + 192; i += 192)
    104     //    Scene::GetDefault()->AddTile(deco_citybackpav, 0, ivec3(i, 288, 0), 0, vec2(1.0f));
     114    for (int i = -(int)(backtime * 288 / 5000.0f); i < 512 + active_deco_width; i += active_deco_width)
     115        Scene::GetDefault()->AddTile(active_deco, 0, ivec3(i, 300, 0), 0, vec2(1.0f));
    105116
    106117    for (int i = -(int)(railtime * 72 / 1000.0f); i < 512 + 72; i += 72)
    107118        Scene::GetDefault()->AddTile(deco_floorrails, 0, ivec3(i, 57, 0), 0, vec2(1.0f));
    108 
    109     Scene::GetDefault()->AddTile(pigeon_flying, (int)(flytime * 2 / 400.0f), ivec3(81, 147, 0), 0, vec2(3.0f));
    110 
    111     Scene::GetDefault()->AddTile(player_walkb, (int)(walktime * 8 / 700.0f), ivec3(120, 81, 0), 0, vec2(3.0f));
    112 
    113     Scene::GetDefault()->AddTile(enemy_casualblue, (int)(walktime * 6 / 700.0f), ivec3(420, 81, 0), 0, vec2(-3.0f, 3.0f));
    114     Scene::GetDefault()->AddTile(enemy_casualblueattack, (int)(walktime * 6 / 700.0f), ivec3(320, 81, 0), 0, vec2(-3.0f, 3.0f));
    115119}
    116120
     
    126130    Tiler::Deregister(deco_floorrails);
    127131
    128     Tiler::Deregister(enemy_casualblue);
    129     Tiler::Deregister(enemy_casualblueattack);
     132    Ticker::Unref(player);
     133    Ticker::Unref(enemy);
    130134
    131     Tiler::Deregister(pigeon_flying);
    132 
    133     Tiler::Deregister(player_dashdown);
    134     Tiler::Deregister(player_death);
    135     Tiler::Deregister(player_fall);
    136     Tiler::Deregister(player_jump);
    137     Tiler::Deregister(player_kickair);
    138     Tiler::Deregister(player_kickfloor);
    139     Tiler::Deregister(player_walkb);
    140     Tiler::Deregister(player_walk);
    141     Tiler::Deregister(player_walkraisefist);
     135    Input::UntrackMouse(this);
    142136}
    143137
  • trunk/mrpigeon/mrpigeon.h

    r1202 r1205  
    11#if !defined __MRPIGEON_H__
    22#define __MRPIGEON_H__
    3 
    4 class MrPigeonData;
    53
    64class MrPigeon : public WorldEntity
     
    1210    char const *GetName() { return "<mrpigeon>"; }
    1311
     12    float GetSpeed() { return speed; }
     13
    1414protected:
    1515    virtual void TickGame(float deltams);
    1616    virtual void TickDraw(float deltams);
     17
     18    class Player *player;
     19    class Enemy *enemy;
    1720
    1821    TileSet *hud_progress,
     
    2326            *deco_citybackpav,
    2427            *deco_floorrails;
    25     TileSet *enemy_casualblue,
    26             *enemy_casualblueattack;
    27     TileSet *pigeon_flying;
    28     TileSet *player_dashdown,
    29             *player_death,
    30             *player_fall,
    31             *player_jump,
    32             *player_kickair,
    33             *player_kickfloor,
    34             *player_walkb,
    35             *player_walk,
    36             *player_walkraisefist;
     28
     29    TileSet *active_deco;
     30    int active_deco_width;
     31
     32    int action;
    3733
    3834    double totaltime;
    39     float walktime, flytime, enemytime, railtime, backtime;
     35    float railtime, backtime;
     36    float speed;
    4037};
    4138
Note: See TracChangeset for help on using the changeset viewer.