Barriers are created at the correct location

This commit is contained in:
2016-04-09 00:02:39 +10:00
parent ec409c8177
commit 1f2d0b8e76
2 changed files with 33 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
/* Copyright: (c) Kayne Ruse 2013-2016
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*/
#pragma once
//the bounds for the objects, mapped to the default sprites
constexpr int BARRIER_BOUNDS_X = 0;
constexpr int BARRIER_BOUNDS_Y = 0;
constexpr int BARRIER_BOUNDS_WIDTH = 96;
constexpr int BARRIER_BOUNDS_HEIGHT = 96;
+5
View File
@@ -21,6 +21,7 @@
*/ */
#include "room_data.hpp" #include "room_data.hpp"
#include "barrier_defines.hpp"
#include "culling_defines.hpp" #include "culling_defines.hpp"
#include "serial_packet.hpp" #include "serial_packet.hpp"
#include "server_utilities.hpp" #include "server_utilities.hpp"
@@ -77,6 +78,10 @@ void RoomData::RunFrame() {
int barrierIndex = barrierMgr.Create(-1); int barrierIndex = barrierMgr.Create(-1);
BarrierData* barrierData = barrierMgr.Find(barrierIndex); BarrierData* barrierData = barrierMgr.Find(barrierIndex);
barrierData->SetRoomIndex(roomIndex); barrierData->SetRoomIndex(roomIndex);
barrierData->SetOrigin({
(CREATURE_BOUNDS_WIDTH - BARRIER_BOUNDS_WIDTH) / 2 + creatureBox.x,
(CREATURE_BOUNDS_HEIGHT - BARRIER_BOUNDS_HEIGHT) / 2 + creatureBox.y,
});
BarrierPacket barrierPacket; BarrierPacket barrierPacket;
barrierPacket.type = SerialPacketType::BARRIER_CREATE; barrierPacket.type = SerialPacketType::BARRIER_CREATE;