; ; ; ; MIT License
; ; ; ; 
; ; ; ; Copyright (c) 2021 Ramiro Hernán García Iten / Raúl Ripoll Pérez / Alexandru Marius Cozma
; ; ; ; 
; ; ; ; Permission is hereby granted, free of charge, to any person obtaining a copy
; ; ; ; of this software and associated documentation files (the "Software"), to deal
; ; ; ; in the Software without restriction, including without limitation the rights
; ; ; ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
; ; ; ; copies of the Software, and to permit persons to whom the Software is
; ; ; ; furnished to do so, subject to the following conditions:
; ; ; ; 
; ; ; ; The above copyright notice and this permission notice shall be included in all
; ; ; ; copies or substantial portions of the Software.
; ; ; ;
; ; ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
; ; ; ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
; ; ; ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
; ; ; ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
; ; ; ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
; ; ; ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
; ; ; ; SOFTWARE.

; ; ; ; ----------------- AUTHORS ------------------
; ; ; ;     Ramiro Hernán García Iten: rhgi1@alu.ua.es
; ; ; ;     Raúl Ripoll Pérez: rrp42@alu.ua.es
; ; ; ;     Alexandru Marius Cozma: amc246@alu.ua.es
; ; ; ; 
; ; ; ; Art by Sara Alfosea - IG: @Slinfir
; ; ; ; ---------------------------------------------

; ; ; ; Third Party source code used
; ; ; ; ----------------------------
; ; ; ; CPCtelera - owned by ronaldo / (Cheesetea, Fremos, ByteRealms) - GNU Lesser General Public License.


;;-----------------------------LICENSE NOTICE------------------------------------
;;  This file is part of CPCtelera: An Amstrad CPC Game Engine 
;;  Copyright (C) 2018 ronaldo / Fremos / Cheesetea / ByteRealms (@FranGallegoBR)
;;
;;  This program is free software: you can redistribute it and/or modify
;;  it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
;;
;;  You should have received a copy of the GNU Lesser General Public License
;;  along with this program.  If not, see <http://www.gnu.org/licenses/>.
;;-------------------------------------------------------------------------------

;;; ==========================================
;;; ==========================================
;;; ENTITY MANAGER HEADER
;;; ==========================================
;;; ==========================================

;;      MACROS
.macro Entity _x, _y, _vx, _vy, _w, _h, _type, _spr, _info, _life, _damage
    .db _x, _y, _vx, _vy, _w, _h, _type
    .dw _spr, 0x0000, 0x0000
    .db _info, _life, _damage
.endm

;; VARIABLES, ARRAY, POINTER
_num_entities::   .db 0
_last_ent_ptr::  .dw _entity_array
_entity_array::
   .ds max_entities*entity_size

;; ENTITIES
_player:
   ;      x    y    vx     vy    w     h   type         spr             _info, _life   #damage
   Entity 20,  0,   0,     0,    6,    40, e_cmp_png,   #_player_spr_0,   #1,     #3,   #1
   
_pillow_hit:
   Entity  40,  60,    0,     0,    5,    16,  e_cmp_hit,  #_pillow_0,        #1,   #1,    #0

_platform_dummy:
   Entity 71,  0,   0,  0, 8, 10, e_cmp_floor,   #_platform, #0,     #1,          #0

_plataforma:
   Entity 20,  40,   0,  0, 8, 10, e_cmp_floor,   #_platform, #0,     #1,          #0

_plataforma2:
   Entity 45,  150,   0,  0,  8, 10, e_cmp_floor,   #_platform, #0,     #1,           #0   ; 1 de vida para el render

_plataforma3:
   Entity 60,  100,   0,  0,  8, 10, e_cmp_floor,   #_platform, #0,     #1,           #0

_murcielago:
   Entity 76,   0,  -1,  0,  4,  8,  e_cmp_enemy, #_bat, e_enemy_bat, #1, #1
_buho:
   Entity 73,   0,  -1,  -2,  7,  20,  e_cmp_enemy, #_owl, e_enemy_owl, #3, #2
_pajaro:
   Entity 76,   0,  -1,  1,  4,  16,  e_cmp_enemy, #_bird, e_enemy_bird, #1, #1
_fantasma:
   Entity 76,   0,  -1,  0,  4,  36,  e_cmp_enemy, #_ghost, e_enemy_ghost, #3, #3

; Inicializa el array de entidades
; Parámetros de entrada

;;      CONSTANTS
max_entities    = 20
entity_size     = 16
hit_distanceX   = 4
hit_distanceY   = 7


;;      ENTITY TYPES
e_cmp_png   =   0x01
e_cmp_floor =   0x02
e_cmp_enemy =   0x04
e_cmp_hit   =   0x08

;; ENTITY PARAMETERS
e_x = 0
e_y = 1
e_vx = 2
e_vy = 3
e_w = 4
e_h = 5
e_type = 6
e_sptr = 7
e_prev_ptr = 9
e_prev_ptr2 = 11
;;TIPOS DE ENEMIGOS
e_enemy_bat     = 0b00000001
e_enemy_owl     = 0b00000010
e_enemy_bird    = 0b00000100
e_enemy_ghost   = 0b00001000
e_enemy_all     = 0b00001111
;;PJ
; Dirección "mirada" -> 0(I) 1 (D)
e_info = 13
e_life = 14
e_damage = 15

_hitON: .db 0x0