Viewport es mou a l'abad
This commit is contained in:
382
data/abad.lua
Normal file
382
data/abad.lua
Normal file
@@ -0,0 +1,382 @@
|
||||
local arcade_config = require("arcade_config")
|
||||
o2aX = arcade_config.org2arc_escala
|
||||
cxr = arcade_config.character_per_row-1
|
||||
cxr2 = arcade_config.character_per_row_base2
|
||||
cw = arcade_config.character_width
|
||||
ch = arcade_config.character_height
|
||||
|
||||
require "dead"
|
||||
|
||||
abad={ x=40, y=24,
|
||||
flip=false,
|
||||
frame=1,
|
||||
wait=0,
|
||||
respawning=0,
|
||||
hab=10,
|
||||
vides=3,
|
||||
energia=40,
|
||||
falling=0,
|
||||
step=0,
|
||||
mustep=1,
|
||||
hurting=0,
|
||||
update=nil,
|
||||
jumpfwd=false,
|
||||
anim={0,1,0,2},
|
||||
bb={x=4,y=0,w=8,h=16},
|
||||
safe={hab=10,x=40,y=24} }
|
||||
|
||||
function abad_nop()
|
||||
end
|
||||
|
||||
function abad_init()
|
||||
abad={ x=40, y=24,
|
||||
flip=false,
|
||||
frame=1,
|
||||
wait=0,
|
||||
respawning=0,
|
||||
hab=10,
|
||||
vides=3,
|
||||
energia=40,
|
||||
falling=0,
|
||||
step=0,
|
||||
mustep=1,
|
||||
draw=abad.draw,
|
||||
hurting=0,
|
||||
update=nil,
|
||||
jumpfwd=false,
|
||||
anim={0,1,0,2},
|
||||
bb={x=4,y=0,w=8,h=16},
|
||||
safe={hab=10,x=40,y=24},
|
||||
move=abad.move }
|
||||
abad.update=abad_state_normal
|
||||
abad.objects={}
|
||||
end
|
||||
|
||||
function abad:move( x, y )
|
||||
self.x = x
|
||||
self.y = y
|
||||
end
|
||||
|
||||
function abad:draw()
|
||||
local flip=abad.flip
|
||||
if abad.update==abad_state_stairs then
|
||||
flip=(((abad.x>>1)+(abad.y>>1))%2)==0
|
||||
end
|
||||
if (abad.respawning==0) or (math.floor(abad.respawning/15)%2==0) then
|
||||
-- draw.surf(abad.frame*16,0,16,16,abad.x,abad.y,16,16,flip)
|
||||
local x, y = viewp:screen_coords(self.x, self.y)
|
||||
-- draw.surf(abad.frame*cw,0,cw,ch,abad.x*o2aX,abad.y*o2aX,cw,ch,flip)
|
||||
draw.surf(abad.frame*cw,0,cw,ch,x,y,cw,ch,flip)
|
||||
end
|
||||
|
||||
if abad.respawning > 0 then
|
||||
abad.respawning=abad.respawning-1
|
||||
end
|
||||
end
|
||||
|
||||
function abad_make_safe()
|
||||
if abad.safe.hab~=abad.hab then
|
||||
abad.safe.hab=abad.hab
|
||||
abad.safe.x=abad.x
|
||||
abad.safe.y=abad.y
|
||||
end
|
||||
end
|
||||
|
||||
function abad_hurt(howmuch)
|
||||
if abad.hurting == 0 and abad.respawning==0 then
|
||||
sound.play(audio_abad_hit)
|
||||
abad.energia=abad.energia-howmuch
|
||||
-- abad.energia=abad.energia
|
||||
if abad.energia<=0 then
|
||||
abad.vides=abad.vides-1
|
||||
if abad.vides==0 then
|
||||
--final de la partida
|
||||
dead.start()
|
||||
music.play(audio_game_over,0)
|
||||
else
|
||||
music.play(audio_life_lost,0)
|
||||
abad.energia=40
|
||||
abad.hab=abad.safe.hab
|
||||
abad.x=abad.safe.x
|
||||
abad.y=abad.safe.y
|
||||
abad.hurting=60
|
||||
abad.update=abad_state_normal
|
||||
abad.bb.y=0
|
||||
abad.bb.h=16
|
||||
abad.respawning=240
|
||||
surf.cls(3)
|
||||
end
|
||||
else
|
||||
surf.cls(3)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function abad_state_normal()
|
||||
abad.frame=0
|
||||
abad.wait=0
|
||||
abad.step=0
|
||||
abad.jumpfwd=false
|
||||
if abad.hurting > 0 then
|
||||
abad.hurting=abad.hurting-1
|
||||
return
|
||||
end
|
||||
|
||||
if abad.falling>0 then
|
||||
if abad.falling>12 then
|
||||
abad_hurt(abad.falling-12)
|
||||
end
|
||||
abad.falling=0
|
||||
end
|
||||
abad_make_safe()
|
||||
|
||||
if key.down(keyRight) or pad.down(btnRight) then
|
||||
abad.update=abad_state_walking
|
||||
abad.flip=false
|
||||
elseif key.down(keyLeft) or pad.down(btnLeft) then
|
||||
abad.update=abad_state_walking
|
||||
abad.flip=true
|
||||
elseif key.down(keyJump) or pad.down(btnJump) then
|
||||
abad.update=abad_state_jumping
|
||||
abad.step=0
|
||||
abad.jumpfwd=false
|
||||
if abad.jump then
|
||||
sound.stop(abad.jump)
|
||||
abad.jump=nil
|
||||
end
|
||||
sound.play(audio_abad_jump)
|
||||
elseif key.down(keyDown) or pad.down(btnDown) then
|
||||
abad.update=abad_state_crouch
|
||||
--elseif btn(KEY_Z) then
|
||||
-- abad.respawning=240
|
||||
elseif key.down(keyShoot) or pad.down(btnShoot) and cacau.hab==-1 then
|
||||
sound.play(audio_abad_shot)
|
||||
abad.update=abad_state_fire
|
||||
abad.wait=0
|
||||
cacau.init(abad.hab,abad.x+8,abad.y+8,abad.flip)
|
||||
end
|
||||
end
|
||||
|
||||
function abad_state_crouch()
|
||||
abad.bb.y=8
|
||||
abad.bb.h=8
|
||||
abad.frame=5
|
||||
abad.wait=0
|
||||
abad.step=0
|
||||
abad.jumpfwd=false
|
||||
|
||||
if not (key.down(keyDown) or pad.down(btnDown)) then
|
||||
abad.update=abad_state_normal
|
||||
abad.bb.y=0
|
||||
abad.bb.h=16
|
||||
end
|
||||
end
|
||||
|
||||
function abad_state_fire()
|
||||
abad.frame=6
|
||||
|
||||
abad.wait=abad.wait+1
|
||||
|
||||
if abad.wait==6 then
|
||||
abad.wait=0
|
||||
abad.update=abad_state_normal
|
||||
end
|
||||
end
|
||||
|
||||
function abad_advance()
|
||||
local inc=12 if abad.flip then inc=2 end
|
||||
local limit=tiletype.block
|
||||
if abad.update~=abad_state_walking then limit=tiletype.half end
|
||||
if not abad.flip and abad.x==84 then
|
||||
abad.hab=abad.hab+1
|
||||
-- imp.reset()
|
||||
abad.x=-4
|
||||
elseif arc_check_tile(abad.x+inc,abad.y+14)<limit then
|
||||
if abad.flip then
|
||||
abad.x=abad.x-2
|
||||
else
|
||||
abad.x=abad.x+2
|
||||
end
|
||||
if abad.x<-4 then
|
||||
abad.hab=abad.hab-1
|
||||
-- imp.reset()
|
||||
abad.x=84
|
||||
end
|
||||
end
|
||||
if arc_check_tile(abad.x+6,abad.y+8)==tiletype.stair then
|
||||
abad.update=abad_state_stairs
|
||||
elseif abad.update==abad_state_stairs then
|
||||
abad.update=abad_state_normal
|
||||
abad.frame=0
|
||||
end
|
||||
end
|
||||
|
||||
function abad_state_walking()
|
||||
abad.wait=abad.wait+1
|
||||
|
||||
if abad.wait==6 then
|
||||
abad.wait=0
|
||||
abad.step=(abad.step+1)%2
|
||||
if abad.step==0 then
|
||||
sound.play(audio_abad_step[abad.mustep],32)
|
||||
abad.mustep = abad.mustep + 1
|
||||
if abad.mustep == 5 then abad.mustep=1 end
|
||||
end
|
||||
abad.frame=abad.anim[abad.step+1]
|
||||
|
||||
abad_advance()
|
||||
|
||||
if arc_check_tile(abad.x+4,abad.y+16)==tiletype.void and ((abad.x+4)&7==0 or arc_check_tile(abad.x+12,abad.y+16)==tiletype.void) then
|
||||
abad.update=abad_state_falling
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
abad_make_safe()
|
||||
|
||||
if key.down(keyJump) or pad.down(btnJump) then
|
||||
if true then return end
|
||||
abad.update=abad_state_jumping
|
||||
abad.step=0
|
||||
abad.jumpfwd=true
|
||||
if abad.jump then
|
||||
sound.stop(abad.jump)
|
||||
abad.jump=nil
|
||||
end
|
||||
sound.play(audio_abad_jump)
|
||||
return
|
||||
elseif key.down(keyDown) or pad.down(btnDown) then
|
||||
abad.update=abad_state_crouch
|
||||
elseif key.down(keyShoot) or pad.down(btnShoot) and cacau.hab==-1 then
|
||||
sound.play(audio_abad_shot)
|
||||
abad.update=abad_state_fire
|
||||
abad.wait=0
|
||||
cacau.init(abad.hab,abad.x+8,abad.y+8,abad.flip)
|
||||
end
|
||||
|
||||
if key.down(keyRight) or pad.down(btnRight) then
|
||||
abad.flip=false
|
||||
elseif key.down(keyLeft) or pad.down(btnLeft) then
|
||||
abad.flip=true
|
||||
elseif abad.wait==0 then
|
||||
abad.update=abad_state_normal
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function abad_state_jumping()
|
||||
abad.frame=3
|
||||
abad.wait=abad.wait+1
|
||||
--print(abad.x,1,50)
|
||||
--print(abad.y,10,50)
|
||||
if abad.wait==6 then
|
||||
abad.wait=0
|
||||
|
||||
if abad.jumpfwd then abad_advance() end
|
||||
|
||||
--local xx=math.floor((abad.x+4)/8)
|
||||
--local yy=math.floor(abad.y/8)
|
||||
--rect(xx*8,yy*8, (xx+2)*8,(yy+1)*8)
|
||||
if abad.step<6 then
|
||||
if abad.y>0 then
|
||||
if check_tile(abad.hab,abad.x+4,abad.y-2)~=tiletype.block then
|
||||
if (abad.x+4)&7==0 or check_tile(abad.hab,abad.x+12,abad.y-2)~=tiletype.block then
|
||||
|
||||
if check_tile(abad.hab,abad.x+4,abad.y-2)==tiletype.switch then
|
||||
-- Executar el switch
|
||||
local xx=math.min(11,math.max(0,math.floor((abad.x+4)/8)))
|
||||
local yy=math.min(5,math.max(0,math.floor((abad.y-2)/8)))
|
||||
switches.start(abad.hab,1+xx+yy*12)
|
||||
--cls(4)
|
||||
elseif (abad.x+4)&7~=0 and check_tile(abad.hab,abad.x+12,abad.y-2)==tiletype.switch then
|
||||
-- Executar el switch
|
||||
local xx=math.min(11,math.max(0,math.floor((abad.x+12)/8)))
|
||||
local yy=math.min(5,math.max(0,math.floor((abad.y-2)/8)))
|
||||
switches.start(abad.hab,1+xx+yy*12)
|
||||
--cls(4)
|
||||
else
|
||||
abad.y=abad.y-2
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
abad.hab=abad.hab-10
|
||||
imp.reset()
|
||||
abad.y=32
|
||||
end
|
||||
elseif abad.step>6 then
|
||||
abad.update=abad_state_falling
|
||||
abad.jump=sound.play(audio_abad_fall)
|
||||
end
|
||||
abad.step=abad.step+1
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function abad_state_falling()
|
||||
abad.frame=3
|
||||
abad.wait=abad.wait+1
|
||||
|
||||
if abad.wait==6 then
|
||||
abad.wait=0
|
||||
|
||||
if abad.jumpfwd then abad_advance() end
|
||||
|
||||
local xx=math.floor((abad.x+4)/8)
|
||||
local yy=math.floor((abad.y+16)/8)
|
||||
|
||||
if abad.y<32 then
|
||||
if (abad.y+16)&7==0 and (check_tile(abad.hab,abad.x+4,abad.y+16)>=tiletype.half or ((abad.x+4)&7~=0 and check_tile(abad.hab,abad.x+12,abad.y+16)>=tiletype.half)) then
|
||||
abad.update=abad_state_normal
|
||||
return
|
||||
end
|
||||
abad.y=abad.y+2
|
||||
abad.falling=abad.falling+1
|
||||
else
|
||||
abad.hab=abad.hab+10
|
||||
-- imp.reset()
|
||||
abad.y=0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function abad_state_stairs()
|
||||
abad.frame=4
|
||||
abad.wait=abad.wait+1
|
||||
|
||||
if abad.wait==6 then
|
||||
abad.wait=0
|
||||
|
||||
if key.down(keyRight) or pad.down(btnRight) then
|
||||
abad.flip=false
|
||||
abad_advance()
|
||||
sound.play(audio_low)
|
||||
elseif key.down(keyLeft) or pad.down(btnLeft) then
|
||||
abad.flip=true
|
||||
abad_advance()
|
||||
sound.play(audio_low)
|
||||
elseif key.down(keyUp) or pad.down(btnUp) then
|
||||
if abad.y>0 then
|
||||
if check_tile(abad.hab,abad.x+4,abad.y+8)==tiletype.stair or (abad.x+4)&7~=0 and check_tile(abad.hab,abad.x+12,abad.y+8)==tiletype.stair then
|
||||
abad.y=abad.y-2
|
||||
sound.play(audio_low)
|
||||
end
|
||||
else
|
||||
abad.hab=abad.hab-10
|
||||
imp.reset()
|
||||
abad.y=32
|
||||
end
|
||||
elseif key.down(keyDown) or pad.down(btnDown) then
|
||||
if abad.y<32 then
|
||||
if check_tile(abad.hab,abad.x+4,abad.y+16)==tiletype.stair or (abad.x+4)&7~=0 and check_tile(abad.hab,abad.x+12,abad.y+16)==tiletype.stair then
|
||||
abad.y=abad.y+2
|
||||
sound.play(audio_low)
|
||||
end
|
||||
else
|
||||
abad.hab=abad.hab+10
|
||||
imp.reset()
|
||||
abad.y=0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
46
data/dead.lua
Normal file
46
data/dead.lua
Normal file
@@ -0,0 +1,46 @@
|
||||
dead={}
|
||||
|
||||
function dead.start()
|
||||
dead.count=0
|
||||
dead.pos={}
|
||||
dead.vel={}
|
||||
for i=1,128 do
|
||||
dead.pos[i]=0
|
||||
dead.vel[i]=(200+math.random(0,399))/400
|
||||
end
|
||||
game_update=dead.update
|
||||
end
|
||||
|
||||
function dead.update()
|
||||
dead.count=dead.count+1
|
||||
for i=1,128 do
|
||||
if dead.pos[i]<96 then
|
||||
dead.pos[i]=dead.pos[i]+dead.vel[i]
|
||||
draw.vline(i-1,0,dead.pos[i],16)
|
||||
end
|
||||
end
|
||||
if dead.count>50 then
|
||||
if dead.count>130 then
|
||||
draw.text("GAME OVER",44,40,2)
|
||||
elseif dead.count>120 then
|
||||
draw.text("GAME OVE",44,40,2)
|
||||
elseif dead.count>110 then
|
||||
draw.text("GAME OV",44,40,2)
|
||||
elseif dead.count>100 then
|
||||
draw.text("GAME O",44,40,2)
|
||||
elseif dead.count>90 then
|
||||
draw.text("GAME",44,40,2)
|
||||
elseif dead.count>80 then
|
||||
draw.text("GAM",44,40,2)
|
||||
elseif dead.count>70 then
|
||||
draw.text("GA",44,40,2)
|
||||
elseif dead.count>60 then
|
||||
draw.text("G",44,40,2)
|
||||
end
|
||||
end
|
||||
|
||||
if (dead.count>250 and (key.press(keyShoot) or pad.press(btnShoot))) or dead.count>500 then
|
||||
game_exit()
|
||||
game_init(true)
|
||||
end
|
||||
end
|
||||
@@ -1,5 +1,7 @@
|
||||
require "fps"
|
||||
require "mapa"
|
||||
require "abad"
|
||||
|
||||
local viewport= require("viewport")
|
||||
|
||||
local arcade_config = require("arcade_config")
|
||||
@@ -8,9 +10,20 @@ local tile_h = arcade_config.tiles_height
|
||||
local res_w = arcade_config.resolucion.width
|
||||
local res_h = arcade_config.resolucion.height
|
||||
|
||||
local viewp = viewport.new()
|
||||
viewp = viewport.new()
|
||||
viewp:position(0,0)
|
||||
|
||||
actors={}
|
||||
|
||||
function game_init(menu)
|
||||
|
||||
abad_init()
|
||||
table.insert(actors,abad)
|
||||
local abad_x, abad_y = arc_mapa_get_coords ( 10, 4, 3 )
|
||||
print(abad_x..", "..abad_y)
|
||||
abad:move(abad_x, abad_y)
|
||||
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
|
||||
|
||||
game_update=update_game
|
||||
end
|
||||
|
||||
@@ -59,19 +72,71 @@ function update_game()
|
||||
---
|
||||
--- mapa_update(abad.hab,cameras[current_camera].hab)
|
||||
|
||||
local vp_x, vp_y = viewp:position()
|
||||
if key.down(keyRight) then
|
||||
if vp_x+1<=(tile_w*mapa_room_cols*(mapa_rooms_per_piso))-(res_w) then vp_x = vp_x+1 end
|
||||
elseif key.down(keyLeft) then
|
||||
if vp_x>0 then vp_x = vp_x-1 end
|
||||
elseif key.down(keyUp) then
|
||||
if vp_y>0 then vp_y = vp_y -1 end
|
||||
elseif key.down(keyDown) then
|
||||
if vp_y+1<=(tile_h*mapa_room_rows*mapa_pisos)-(res_h) then vp_y = vp_y+1 end
|
||||
end
|
||||
--local vp_x, vp_y = viewp:position()
|
||||
--if key.down(keyRight) then
|
||||
-- if vp_x+1<=(tile_w*mapa_room_cols*(mapa_rooms_per_piso))-(res_w) then vp_x = vp_x+1 end
|
||||
--elseif key.down(keyLeft) then
|
||||
-- if vp_x>0 then vp_x = vp_x-1 end
|
||||
--elseif key.down(keyUp) then
|
||||
-- if vp_y>0 then vp_y = vp_y -1 end
|
||||
--elseif key.down(keyDown) then
|
||||
-- if vp_y+1<=(tile_h*mapa_room_rows*mapa_pisos)-(res_h) then vp_y = vp_y+1 end
|
||||
--end
|
||||
|
||||
if key.press(key.N1) then
|
||||
local hab = math.random(0, 79)
|
||||
local abad_x, abad_y = arc_mapa_get_coords ( hab, 4, 3 )
|
||||
print(abad_x..", "..abad_y)
|
||||
abad:move(abad_x, abad_y)
|
||||
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
|
||||
end
|
||||
if key.press(key.N0) then
|
||||
local abad_x, abad_y = arc_mapa_get_coords ( 10, 4, 3 )
|
||||
print(abad_x..", "..abad_y)
|
||||
abad:move(abad_x, abad_y)
|
||||
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
|
||||
end
|
||||
for key,actor in pairs(actors) do
|
||||
actor:update()
|
||||
--if actor.hab==cacau.hab and actor~=abad then
|
||||
-- if aabb(actor,cacau) then
|
||||
-- if actor.hit~=nil then
|
||||
-- actor:hit()
|
||||
-- cacau.hab=-1
|
||||
-- end
|
||||
-- end
|
||||
--end
|
||||
end
|
||||
local vp_x = viewp.x
|
||||
local vp_y = viewp.y
|
||||
--viewp:position(vp_x, vp_y)
|
||||
|
||||
local vp_center_offset_x = (viewp.width >> 1)
|
||||
local vp_center_offset_y = (viewp.height >> 1)
|
||||
|
||||
vp_x = abad.x - vp_center_offset_x
|
||||
if vp_x < 0 then vp_x = 0 end
|
||||
|
||||
vp_y = abad.y - vp_center_offset_y
|
||||
if vp_y < 0 then vp_y = 0 end
|
||||
|
||||
viewp:position(vp_x, vp_y)
|
||||
render_map(sf_mapa, tiles, vp_x, vp_y)
|
||||
|
||||
for key,actor in pairs(actors) do
|
||||
-- if actor.hab==hab then
|
||||
if true then
|
||||
actor:draw()
|
||||
end
|
||||
end
|
||||
|
||||
fps_print()
|
||||
viewp:print()
|
||||
msg_print(0,14,"ABAD= "..abad.x..", "..abad.y)
|
||||
msg_print(0,21,"VIEW= "..vp_x..", "..vp_y)
|
||||
end
|
||||
|
||||
function msg_print(x, y, msg )
|
||||
draw.rectf(x,y,45,14,16)
|
||||
draw.text(msg,x+1,y+1,2)
|
||||
end
|
||||
@@ -153,6 +153,50 @@ function check_tile(hab,x,y)
|
||||
end
|
||||
end
|
||||
|
||||
function arc_mapa_get_coords ( hab, tile_x , tile_y )
|
||||
-- La primera habitació es la 0
|
||||
-- El primer tile es 0
|
||||
x = ((hab % 10)*mapa_room_cols + tile_x)*arcade_config.tiles_width
|
||||
y = (math.floor(hab/10)*mapa_room_rows + tile_y)*arcade_config.tiles_height
|
||||
|
||||
return x, y
|
||||
end
|
||||
|
||||
function arc_mapa_get_map_coords ( x, y )
|
||||
local tw = arcade_config.tiles_width
|
||||
local th = arcade_config.tiles_height
|
||||
local cols = mapa_room_cols
|
||||
local rows = mapa_room_rows
|
||||
local rooms_per_floor = mapa_rooms_per_piso
|
||||
|
||||
local calc_col = math.floor(x / tw) % cols
|
||||
local calc_row = math.floor(y / th) % rows
|
||||
local calc_room = math.floor(y / (th * rows))*rooms_per_floor+math.floor(x / (tw * cols))
|
||||
|
||||
return calc_room, calc_col, calc_row
|
||||
end
|
||||
|
||||
function arc_check_tile(x,y)
|
||||
-- local xx=math.min(11,math.max(0,math.floor(x/8)))
|
||||
-- local yy=math.min(5,math.max(0,math.floor(y/8)))
|
||||
--rect(xx*8,yy*8,xx*8+8,yy*8+8,3)
|
||||
local hab, xx, yy = arc_mapa_get_map_coords(x, y)
|
||||
local tile=mapa_get_tile(hab,xx,yy)
|
||||
if tile<8 then
|
||||
return tiletype.half
|
||||
elseif tile<15 then
|
||||
return tiletype.stair
|
||||
elseif tile==15 then
|
||||
return tiletype.switch
|
||||
elseif tile<64 then
|
||||
return tiletype.block
|
||||
elseif tile==111 then
|
||||
return tiletype.nonpc
|
||||
else
|
||||
return tiletype.void
|
||||
end
|
||||
end
|
||||
|
||||
pix={14,10,7,1,0,0,0,0,4,4,4,4,0,0,0,8,14,14,14,14,14,14,0,0,10,10,10,10,10,10,10,10,7,7,7,7,7,7,2,2,1,1,1,1,1,1,12,12,1,1,1,9,9,9,10,10,10,0,0,0,0,0,0,0}
|
||||
|
||||
function mapa_create_minimap()
|
||||
|
||||
BIN
data/tiles.gif
BIN
data/tiles.gif
Binary file not shown.
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 12 KiB |
@@ -12,9 +12,15 @@ function viewport.new()
|
||||
print=viewport.print,
|
||||
room=viewport.coord2room,
|
||||
roomXY= viewport.room2coord,
|
||||
tile= viewport.coord2tile }
|
||||
tile= viewport.coord2tile,
|
||||
screen_coords = viewport.screen_coords }
|
||||
end
|
||||
|
||||
function viewport:screen_coords ( x, y )
|
||||
local scr_x = x-self.x
|
||||
local scr_y = y-self.y
|
||||
return scr_x, scr_y
|
||||
end
|
||||
|
||||
function viewport:coord2tile ()
|
||||
local tw = arcade_config.tiles_width
|
||||
|
||||
Reference in New Issue
Block a user