Changeset 226


Ignore:
Timestamp:
Jan 18, 2011, 3:51:06 PM (10 years ago)
Author:
sam
Message:

New class for board pieces.

Location:
trunk/monsterz
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/monsterz/Makefile.am

    r223 r226  
    22noinst_PROGRAMS = monsterz
    33
    4 monsterz_SOURCES = monsterz.cpp game.cpp game.h board.cpp board.h
     4monsterz_SOURCES = \
     5    monsterz.cpp monsterz.h game.cpp game.h board.cpp board.h piece.cpp piece.h
    56monsterz_CXXFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@
    67monsterz_LDADD = $(top_builddir)/src/liblol.a
  • trunk/monsterz/board.cpp

    r223 r226  
    1818#include "core.h"
    1919#include "board.h"
     20#include "piece.h"
     21#include "monsterz.h"
    2022
    2123/*
     
    2931private:
    3032    Game *game;
    31     int background, board, tiler;
     33    int screen, board;
     34    Piece *pieces[8][8];
    3235};
    3336
     
    4144    data->game = game;
    4245    Ticker::Ref(game);
    43     data->background = Tiler::Register("monsterz/background.png", 640, 480, 1.0f);
    44     data->board = Tiler::Register("monsterz/board.png", 384, 384, 1.0f);
    45     data->tiler = Tiler::Register("monsterz/tiles.png", 48, 48, 1.0f);
     46    data->screen = Tiler::Register(PNG_BACKGROUND, 640, 480, 1.0f);
     47    data->board = Tiler::Register(PNG_BOARD, 384, 384, 1.0f);
     48
     49    for (int j = 0; j < 8; j++)
     50        for (int i = 0; i < 8; i++)
     51        {
     52            data->pieces[j][i] = new Piece(game);
     53            Ticker::Ref(data->pieces[j][i]);
     54        }
    4655}
    4756
     
    5564    Entity::TickDraw(deltams);
    5665
    57     data->game->GetScene()->AddTile((data->background << 16) | 0, 0, 1050, 0, 0);
     66    data->game->GetScene()->AddTile((data->screen << 16) | 0, 0, 1050, 0, 0);
    5867    data->game->GetScene()->AddTile((data->board << 16) | 0, 24, 912, 1, 0);
    59 
    60     for (int j = 0; j < 8; j++)
    61         for (int i = 0; i < 8; i++)
    62     {
    63         int id = 28 + ((i + 3) * (j + 1) % 10) * 3 + ((i ^ (j + 2)) % 5);
    64         id += (id % 5) / 4;
    65         data->game->GetScene()->AddTile((data->tiler << 16) | id,
    66                                         i * 48 + 24, j * 48 + 177, 2, 0);
    67     }
    6868}
    6969
     
    7171{
    7272    Ticker::Unref(data->game);
    73     Tiler::Deregister(data->tiler);
     73    for (int j = 0; j < 8; j++)
     74        for (int i = 0; i < 8; i++)
     75            Ticker::Unref(data->pieces[j][i]);
    7476    Tiler::Deregister(data->board);
    75     Tiler::Deregister(data->background);
     77    Tiler::Deregister(data->screen);
    7678    delete data;
    7779}
Note: See TracChangeset for help on using the changeset viewer.