[FIX] Viewport tremolant al tornar del jefe... per un =...
This commit is contained in:
+1
-1
@@ -41,7 +41,7 @@ function imp.new(_hab,_x,_y)
|
||||
pattern= pattern.new(),
|
||||
analisis = {}, -- memoria per a guardar el resultat de l'analisis
|
||||
step_length=1,
|
||||
energia=21,
|
||||
energia=1,
|
||||
max_energia=21,
|
||||
jump_height=0,
|
||||
max_jump_height=24,
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ function mini.init()
|
||||
logo_config(font_sf)
|
||||
surf.target(0)
|
||||
surf.cls(16)
|
||||
states:executar("logo")
|
||||
states:executar("game")
|
||||
end
|
||||
|
||||
function mini.update()
|
||||
|
||||
+1
-1
@@ -180,7 +180,7 @@ function stages.stage1_init()
|
||||
tiles_layer2.new(78,6,2,128,208,16,16, tiles_layer2.update_aranya, tiles_layer2.draw_aranya)
|
||||
|
||||
local abad_x, abad_y = coords.room_to_world ( 10, 4, 3 )
|
||||
-- local abad_x, abad_y = coords.room_to_world ( 54, 8, 3 )
|
||||
local abad_x, abad_y = coords.room_to_world ( 54, 8, 3 )
|
||||
-- table.insert( actors, trigger.new(8,4,3,triggers.escena_stage1_ending,"stage1 ending","TR09") )
|
||||
-- local abad_x, abad_y = coords.room_to_world ( 8, 9, 3 )
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ end
|
||||
|
||||
function stages.stage1_boss_intro_update()
|
||||
if stage1_boss.time==0 then
|
||||
start_scene(scenes.lluita_imp, nil, false)
|
||||
-- start_scene(scenes.lluita_imp, nil, false)
|
||||
stages.stage1_boss_ready()
|
||||
end
|
||||
|
||||
|
||||
+50
-32
@@ -20,7 +20,8 @@ function viewport.new(_width, _height)
|
||||
range = nil, -- rang de moviment quan està fixat {r= , l=, u=, d= }
|
||||
fixed_coord = nil, -- coordenades fixades
|
||||
smooth_adjust = nil,
|
||||
adjust_speed = 2
|
||||
adjust_speed = 2,
|
||||
fixed_to_free_position = viewport.fixed_to_free_position
|
||||
}
|
||||
end
|
||||
|
||||
@@ -66,6 +67,52 @@ function viewport:coord2room ()
|
||||
return coords.world_to_room(self.x, self.y)
|
||||
end
|
||||
|
||||
function viewport:fixed_to_free_position(nx, ny)
|
||||
local speed_x = self.adjust_speed
|
||||
local speed_y = self.adjust_speed
|
||||
local sm_x = self.smooth_adjust.x
|
||||
local sm_y = self.smooth_adjust.y
|
||||
|
||||
-- print("FIXED TO FREE")
|
||||
-- print(" nx,ny= "..nx.." , "..ny)
|
||||
-- if sm_x~=nil then print(" sm_x= "..sm_x) else print(" sm_x= nil") end
|
||||
-- if sm_y~=nil then print(" sm_y= "..sm_y) else print(" sm_y= nil") end
|
||||
-- print(" sp_x,sp_y= "..speed_x.." , "..speed_y)
|
||||
-- print("")
|
||||
|
||||
-- Ajustar eix X
|
||||
self.x = nx
|
||||
if sm_x~=nil then
|
||||
if math.abs(nx-sm_x)<=speed_x then
|
||||
sm_x = nil
|
||||
else
|
||||
if nx<sm_x-speed_x then speed_x = -speed_x end
|
||||
self.x=sm_x+speed_x
|
||||
sm_x =sm_x+speed_x
|
||||
end
|
||||
-- actualitzar eix smooth x
|
||||
self.smooth_adjust.x = sm_x
|
||||
end
|
||||
|
||||
-- Ajustar eix Y
|
||||
self.y = ny
|
||||
if sm_y~=nil then
|
||||
if math.abs(ny-sm_y)<=speed_y then
|
||||
sm_y = nil
|
||||
else
|
||||
if ny<sm_y-speed_y then speed_y = -speed_y end
|
||||
self.y=sm_y+speed_y
|
||||
sm_y =sm_y+speed_y
|
||||
end
|
||||
-- actualitzar eix smooth y
|
||||
self.smooth_adjust.y = sm_y
|
||||
end
|
||||
|
||||
if sm_x == nil and sm_y == nil then
|
||||
self.smooth_adjust = nil
|
||||
end
|
||||
end
|
||||
|
||||
function viewport:position(x, y)
|
||||
local nx = (x ~= nil) and x or self.x
|
||||
local ny = (y ~= nil) and y or self.y
|
||||
@@ -74,39 +121,10 @@ function viewport:position(x, y)
|
||||
if self.smooth_adjust == nil then
|
||||
self.x = nx
|
||||
self.y = ny
|
||||
self.range=nil
|
||||
else
|
||||
-- viewport lliure després de fixar-lo -> Ajustar suau
|
||||
local speed_x = self.adjust_speed
|
||||
local speed_y = self.adjust_speed
|
||||
local sm_x = self.smooth_adjust.x
|
||||
local sm_y = self.smooth_adjust.y
|
||||
self.x = nx
|
||||
if sm_x~=nil then
|
||||
if math.abs(nx-sm_x)<speed_x then
|
||||
sm_x = nil
|
||||
else
|
||||
if nx<sm_x-speed_x then speed_x = -speed_x end
|
||||
self.x=sm_x+speed_x
|
||||
sm_x =sm_x+speed_x
|
||||
end
|
||||
self.smooth_adjust.x = sm_x
|
||||
end
|
||||
|
||||
self.y = ny
|
||||
if sm_y~=nil then
|
||||
if math.abs(ny-sm_y)<speed_y then
|
||||
sm_y = nil
|
||||
else
|
||||
if ny<sm_y-speed_y then speed_y = -speed_y end
|
||||
self.y=sm_y+speed_y
|
||||
sm_y =sm_y+speed_y
|
||||
end
|
||||
self.smooth_adjust.y = sm_y
|
||||
end
|
||||
|
||||
if sm_x == nil and sm_y == nil then
|
||||
self.smooth_adjust = nil
|
||||
end
|
||||
self:fixed_to_free_position(nx, ny)
|
||||
end
|
||||
else
|
||||
-- viewport fixe
|
||||
|
||||
Reference in New Issue
Block a user