Changeset 740


Ignore:
Timestamp:
Mar 14, 2011, 2:40:24 AM (10 years ago)
Author:
sam
Message:

monsterz: create a Score class to display the score text and increment it
progressively.

Location:
trunk/monsterz
Files:
1 added
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/monsterz/Makefile.am

    r635 r740  
    44monsterz_SOURCES = \
    55    monsterz.cpp monsterz.h title.cpp title.h interface.cpp interface.h \
    6     board.cpp board.h piece.cpp piece.h mash.cpp mash.h thumbs.cpp thumbs.h
     6    board.cpp board.h piece.cpp piece.h mash.cpp mash.h thumbs.cpp thumbs.h \
     7    score.cpp score.h
    78monsterz_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@
    89monsterz_LDADD =
  • trunk/monsterz/board.cpp

    r737 r740  
    2424#include "board.h"
    2525#include "piece.h"
     26#include "score.h"
    2627#include "thumbs.h"
    2728#include "mash.h"
     
    6162    int next[2], rotation;
    6263
    63     Text *scoretext;
    64     int score;
     64    Score *score;
    6565
    6666    Mash *mashes;
     
    155155    data->whipdelay = 0.0f;
    156156
    157     data->scoretext = new Text(NULL, "monsterz/gfx/font2.png");
    158     data->scoretext->SetAlign(Text::ALIGN_RIGHT);
    159     data->scoretext->SetPos(vec3i(624, 432, 20));
    160     Ticker::Ref(data->scoretext);
    161     data->score = 0;
     157    data->score = new Score(0);
     158    data->score->SetPos(vec3i(624, 432, 20));
     159    Ticker::Ref(data->score);
    162160
    163161    position = vec3i(24, 72, 1);
     
    188186            it = &(*it)->nextmash;
    189187    }
    190 
    191     /* Update score */
    192     data->scoretext->SetInt(data->score);
    193188
    194189    switch (data->state)
     
    455450    }
    456451
     452    int multiplier = 20;
     453
    457454    /* Remove matching pieces and store them in Mash objects */
    458455    do
     
    516513        mash->nextmash = data->mashes;
    517514        data->mashes = mash;
     515
     516        data->score->Add(multiplier);
     517        multiplier *= 2;
    518518    }
    519519    while(ListMashes(list));
     
    818818    }
    819819    Ticker::Unref(data->thumbs);
    820     Ticker::Unref(data->scoretext);
     820    Ticker::Unref(data->score);
    821821    while (data->mashes)
    822822    {
  • trunk/monsterz/score.h

    r739 r740  
    1010
    1111//
    12 // The Thumbs class
     12// The Score class
    1313// ---------------
    1414//
    1515
    16 #if !defined __MONSTERZ_THUMBS_H__
    17 #define __MONSTERZ_THUMBS_H__
     16#if !defined __MONSTERZ_SCORE_H__
     17#define __MONSTERZ_SCORE_H__
    1818
    1919#include "monsterz.h"
    2020
    21 class ThumbsData;
     21class ScoreData;
    2222
    23 class Thumbs : public WorldEntity
     23class Score : public Text
    2424{
    2525public:
    26     Thumbs(int npieces);
    27     virtual ~Thumbs();
     26    Score(int score);
     27    virtual ~Score();
    2828
    29     char const *GetName() { return "<thumbs>"; }
     29    char const *GetName() { return "<score>"; }
    3030
    31     void SetMax(int npieces);
    32     void AddCount(int id, int count);
    33     int GetCount(int id);
     31    void Add(int points);
    3432
    3533protected:
     
    3836
    3937private:
    40     ThumbsData *data;
     38    ScoreData *data;
    4139};
    4240
    43 #endif // __MONSTERZ_THUMBS_H__
     41#endif // __MONSTERZ_SCORE_H__
    4442
  • trunk/monsterz/thumbs.h

    r423 r740  
    1111//
    1212// The Thumbs class
    13 // ---------------
     13// ----------------
    1414//
    1515
Note: See TracChangeset for help on using the changeset viewer.