Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions engine/compilers/Make-32bit/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ clean:
.PHONY: all debug release clean

-include x Torque2D.mk
-include x TmxParser.mk
-include x zlib
-include x lpng
-include x ljpeg
Expand Down
64 changes: 64 additions & 0 deletions engine/compilers/Make-32bit/TmxParser.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# I release this sample under the MIT license: free for any use, provided
# you hold me harmless from any such use you make, and you retain my
# copyright on the actual sources.
# Copyright 2005 Jon Watte.

LIBNAME := TmxParser
SOURCES := $(shell find ../../lib/TmxParser -name "*.cpp")

LDFLAGS_TmxParser := -g -m32

CFLAGS_TmxParser := -MMD -I. -m32 -msse -mmmx -march=i686

CFLAGS_TmxParser += -I../../lib/TmxParser
CFLAGS_TmxParser += -I../../lib/TmxParser/base64
CFLAGS_TmxParser += -I../../lib/TmxParser/tinyxml

CFLAGS_TmxParser += -DUNICODE
CFLAGS_TmxParser += -DLINUX

CFLAGS_DEBUG_TmxParser := $(CFLAGS_TmxParser) -ggdb
CFLAGS_DEBUG_TmxParser += -DTORQUE_DEBUG
CFLAGS_DEBUG_TmxParser += -DTORQUE_DEBUG_GUARD
CFLAGS_DEBUG_TmxParser += -DTORQUE_NET_STATS

CFLAGS_TmxParser += -O3

CC := gcc
LD := gcc

TARGET_TmxParser := lib/libTmxParser.a
TARGET_TmxParser_DEBUG := lib/libTmxParser_DEBUG.a

LIB_TARGETS += $(TARGET_TmxParser)
LIB_TARGETS_DEBUG += $(TARGET_TmxParser_DEBUG)

OBJS_TmxParser := $(patsubst ../../lib/TmxParser/%,Release/TmxParser/%.o,$(SOURCES))
OBJS_TmxParser_DEBUG := $(patsubst ../../lib/TmxParser/%,Debug/TmxParser/%.o,$(SOURCES))

# Deriving the variable name from the target name is the secret sauce
# of the build system.
#
$(TARGET_TmxParser): $(OBJS_TmxParser)
@mkdir -p $(dir $@)
ar cr $@ $(OBJS_TmxParser)

$(TARGET_TmxParser_DEBUG): $(OBJS_TmxParser_DEBUG)
@mkdir -p $(dir $@)
ar cr $@ $(OBJS_TmxParser_DEBUG)

Release/TmxParser/%.o: ../../lib/TmxParser/%
@mkdir -p $(dir $@)
$(CC) -c $(CFLAGS_TmxParser) $< -o $@

Debug/TmxParser/%.o: ../../lib/TmxParser/%
@mkdir -p $(dir $@)
$(CC) -c $(CFLAGS_DEBUG_TmxParser) $< -o $@

release_TmxParser: $(TARGET_TmxParser)
debug_TmxParser: $(TARGET_TmxParser_DEBUG)

.PHONY: debug_TmxParser release_TmxParser

DEPS += $(patsubst %.o,%.d,$(OBJS_TmxParser))
DEPS += $(patsubst %.o,%.d,$(OBJS_TmxParser_DEBUG))
3 changes: 3 additions & 0 deletions engine/compilers/Make-32bit/Torque2D.mk
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ CFLAGS += -I../../lib/freetype
CFLAGS += -I../../lib/libvorbis/include
CFLAGS += -I../../lib/libogg/include
CFLAGS += -I../../lib/openal/LINUX/
CFLAGS += -I../../lib/TmxParser/

CFLAGS += -DLINUX
CFLAGS += -Di386

CFLAGS += -Wno-invalid-offsetof


CFLAGS_DEBUG := $(CFLAGS) -ggdb
CFLAGS_DEBUG += -DTORQUE_DEBUG
Expand Down
1 change: 1 addition & 0 deletions engine/compilers/Make-64bit/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ clean:
.PHONY: all debug release clean

-include x Torque2D.mk
-include x TmxParser.mk
-include x zlib
-include x lpng
-include x ljpeg
Expand Down
64 changes: 64 additions & 0 deletions engine/compilers/Make-64bit/TmxParser.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# I release this sample under the MIT license: free for any use, provided
# you hold me harmless from any such use you make, and you retain my
# copyright on the actual sources.
# Copyright 2005 Jon Watte.

LIBNAME := TmxParser
SOURCES := $(shell find ../../lib/TmxParser -name "*.cpp")

LDFLAGS_TmxParser := -g -m64

CFLAGS_TmxParser := -MMD -I. -m64 -msse -mmmx -march=x86-64

CFLAGS_TmxParser += -I../../lib/TmxParser
CFLAGS_TmxParser += -I../../lib/TmxParser/base64
CFLAGS_TmxParser += -I../../lib/TmxParser/tinyxml

CFLAGS_TmxParser += -DUNICODE
CFLAGS_TmxParser += -DLINUX

CFLAGS_DEBUG_TmxParser := $(CFLAGS_TmxParser) -ggdb
CFLAGS_DEBUG_TmxParser += -DTORQUE_DEBUG
CFLAGS_DEBUG_TmxParser += -DTORQUE_DEBUG_GUARD
CFLAGS_DEBUG_TmxParser += -DTORQUE_NET_STATS

CFLAGS_TmxParser += -O3

CC := gcc
LD := gcc

TARGET_TmxParser := lib/libTmxParser.a
TARGET_TmxParser_DEBUG := lib/libTmxParser_DEBUG.a

LIB_TARGETS += $(TARGET_TmxParser)
LIB_TARGETS_DEBUG += $(TARGET_TmxParser_DEBUG)

OBJS_TmxParser := $(patsubst ../../lib/TmxParser/%,Release/TmxParser/%.o,$(SOURCES))
OBJS_TmxParser_DEBUG := $(patsubst ../../lib/TmxParser/%,Debug/TmxParser/%.o,$(SOURCES))

# Deriving the variable name from the target name is the secret sauce
# of the build system.
#
$(TARGET_TmxParser): $(OBJS_TmxParser)
@mkdir -p $(dir $@)
ar cr $@ $(OBJS_TmxParser)

$(TARGET_TmxParser_DEBUG): $(OBJS_TmxParser_DEBUG)
@mkdir -p $(dir $@)
ar cr $@ $(OBJS_TmxParser_DEBUG)

Release/TmxParser/%.o: ../../lib/TmxParser/%
@mkdir -p $(dir $@)
$(CC) -c $(CFLAGS_TmxParser) $< -o $@

Debug/TmxParser/%.o: ../../lib/TmxParser/%
@mkdir -p $(dir $@)
$(CC) -c $(CFLAGS_DEBUG_TmxParser) $< -o $@

release_TmxParser: $(TARGET_TmxParser)
debug_TmxParser: $(TARGET_TmxParser_DEBUG)

.PHONY: debug_TmxParser release_TmxParser

DEPS += $(patsubst %.o,%.d,$(OBJS_TmxParser))
DEPS += $(patsubst %.o,%.d,$(OBJS_TmxParser_DEBUG))
3 changes: 3 additions & 0 deletions engine/compilers/Make-64bit/Torque2D.mk
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,14 @@ CFLAGS += -I../../lib/freetype
CFLAGS += -I../../lib/libvorbis/include
CFLAGS += -I../../lib/libogg/include
CFLAGS += -I../../lib/openal/LINUX/
CFLAGS += -I../../lib/TmxParser/

CFLAGS += -DLINUX
CFLAGS += -D__amd64__
CFLAGS += -DTORQUE_64

CFLAGS += -Wno-invalid-offsetof


CFLAGS_DEBUG := $(CFLAGS) -ggdb
CFLAGS_DEBUG += -DTORQUE_DEBUG
Expand Down
42 changes: 42 additions & 0 deletions engine/lib/TmxParser/Tmx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//-----------------------------------------------------------------------------
// TmxImage.h
//
// Copyright (c) 2010-2013, Tamir Atias
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL TAMIR ATIAS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: Tamir Atias
//-----------------------------------------------------------------------------
#pragma once

#include "TmxMap.h"
#include "TmxTileset.h"
#include "TmxTile.h"
#include "TmxImage.h"
#include "TmxLayer.h"
#include "TmxObject.h"
#include "TmxObjectGroup.h"
#include "TmxEllipse.h"
#include "TmxPolygon.h"
#include "TmxPolyline.h"
#include "TmxPropertySet.h"
#include "TmxUtil.h"
#include "TmxImageLayer.h"
41 changes: 41 additions & 0 deletions engine/lib/TmxParser/TmxEllipse.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//-----------------------------------------------------------------------------
// TmxPolygon.cpp
//
// Copyright (c) 2010-2013, Tamir Atias
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL TAMIR ATIAS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: Tamir Atias
//-----------------------------------------------------------------------------
#include "tinyxml/tinyxml.h"

#include "TmxEllipse.h"

namespace Tmx
{
Ellipse::Ellipse( int _x, int _y, int width, int height )
: x(_x+(width/2))
, y(_y+(height/2))
, radiusX(width/2)
, radiusY(height/2)
{
}
}
64 changes: 64 additions & 0 deletions engine/lib/TmxParser/TmxEllipse.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//-----------------------------------------------------------------------------
// TmxPolygon.h
//
// Copyright (c) 2010-2013, Tamir Atias
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL TAMIR ATIAS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: Tamir Atias
//-----------------------------------------------------------------------------
#pragma once

#include <vector>

#include "TmxPoint.h"

class TiXmlNode;

namespace Tmx
{
//-------------------------------------------------------------------------
// Class to store a Polygon of an Object.
//-------------------------------------------------------------------------
class Ellipse
{
public:
Ellipse( int x, int y, int width, int height );

// Get the center of the object, in pixels.
int GetCenterX() const { return x; }

// Get the center of the object, in pixels.
int GetCenterY() const { return y; }

// Get the RadiusX of the object, in pixels.
int GetRadiusX() const { return radiusX; }

// Get the RadiusY of the object, in pixels.
int GetRadiusY() const { return radiusY; }

private:
int x;
int y;
int radiusX;
int radiusY;
};
};
60 changes: 60 additions & 0 deletions engine/lib/TmxParser/TmxImage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//-----------------------------------------------------------------------------
// TmxImage.cpp
//
// Copyright (c) 2010-2013, Tamir Atias
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL TAMIR ATIAS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: Tamir Atias
//-----------------------------------------------------------------------------
#include "tinyxml/tinyxml.h"

#include "TmxImage.h"

namespace Tmx
{
Image::Image()
: source()
, width()
, height()
, transparent_color()
{}

Image::~Image()
{}

void Image::Parse(const TiXmlNode *imageNode)
{
const TiXmlElement* imageElem = imageNode->ToElement();

// Read all the attribute into member variables.
source = imageElem->Attribute("source");

imageElem->Attribute("width", &width);
imageElem->Attribute("height", &height);

const char *trans = imageElem->Attribute("trans");
if (trans)
{
transparent_color = trans;
}
}
};
Loading