Commit 71b12e22 authored by Colomban Wendling's avatar Colomban Wendling

First attempt for tile object class

parent 09f60243
......@@ -18,6 +18,7 @@ AC_SUBST(ovccincludedir)
# Checks for programs.
AC_PROG_CC
AM_PROG_VALAC([0.8])
AC_PROG_LIBTOOL
AC_CHECK_PROGS([GLIB_GENMARSHAL], [glib-genmarshal], [NONE])
AC_CHECK_PROGS([GLIB_MKENUMS], [glib-mkenums], [NONE])
......
......@@ -10,6 +10,7 @@ libovcc_la_SOURCES = enumtypes.c \
player.c \
stack.c \
tile.c \
tileobject.vala \
tileset.c \
tilesdef.c \
xmlutils.c
......
/*
*
* Copyright (C) 2011 Colomban Wendling <ban@herbesfolles.org>
* Jonathan Michalon <studios.chalmion@no-log.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OVCC
{
[Flags]
public enum TileObjectLinks
{
TOP_LEFT = 1 << 0,
TOP_CENTER = 1 << 1,
TOP_RIGHT = 1 << 2,
TOP = TOP_LEFT | TOP_CENTER | TOP_RIGHT,
RIGHT_LEFT = 1 << 3,
RIGHT_CENTER = 1 << 4,
RIGHT_RIGHT = 1 << 5,
RIGHT = RIGHT_LEFT | RIGHT_CENTER | RIGHT_RIGHT,
BOTTOM_LEFT = 1 << 6,
BOTTOM_CENTER = 1 << 7,
BOTTOM_RIGHT = 1 << 8,
BOTTOM = BOTTOM_LEFT | BOTTOM_CENTER | BOTTOM_RIGHT,
LEFT_LEFT = 1 << 9,
LEFT_CENTER = 1 << 10,
LEFT_RIGHT = 1 << 11,
LEFT = LEFT_LEFT | LEFT_CENTER | LEFT_RIGHT
}
public enum TileObjectType
{
FIELD,
PATH,
CITY,
MONASTERY
}
[Flags]
public enum TileObjectAttributes
{
NONE = 0,
BONUS = 1 << 0
}
public class TileObject : Object
{
public string name { get; construct; }
public TileObjectType otype { get; construct; }
public TileObjectAttributes attributes { get; construct; }
public TileObjectLinks links { get; private set; }
public TileObject (string name,
TileObjectType type,
TileObjectAttributes attributes,
TileObjectLinks links)
{
Object (name: name, otype: type, attributes: attributes, links: links);
}
private inline uint clock_mod (int x,
uint mod)
{
if (x < 0) {
return (mod - ((uint)(-x) % mod)) % mod;
} else {
return (uint)x % mod;
}
}
public void rotate (int steps)
{
var wise = clock_mod (steps, 4) * 3;
var tmp = this.links & ((1 << (wise + 1)) - 1);
this.links = (TileObjectLinks)((this.links << wise) | tmp << (12 - wise));
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment