Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tales of MajEyal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
yutio888
Tales of MajEyal
Commits
58555f98
Commit
58555f98
authored
14 years ago
by
dg
Browse files
Options
Downloads
Patches
Plain Diff
plop
git-svn-id:
http://svn.net-core.org/repos/t-engine4@2479
51575b47-30f0-44d4-a5cc-537603b46e54
parent
7728a382
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
game/engines/default/engine/Map.lua
+8
-0
8 additions, 0 deletions
game/engines/default/engine/Map.lua
game/modules/tome/data/zones/trollmire/zone.lua
+8
-8
8 additions, 8 deletions
game/modules/tome/data/zones/trollmire/zone.lua
src/map.c
+39
-23
39 additions, 23 deletions
src/map.c
with
55 additions
and
31 deletions
game/engines/default/engine/Map.lua
+
8
−
0
View file @
58555f98
...
...
@@ -725,6 +725,14 @@ function _M:isOnScreen(x, y)
return
false
end
--- Get the screen offset where to start drawing (upper corner)
function
_M
:
getScreenUpperCorner
()
local
sx
,
sy
=
self
.
_map
:
getScroll
()
local
x
=
-
self
.
mx
*
self
.
tile_w
*
self
.
zoom
+
self
.
display_x
+
sx
local
y
=
-
self
.
my
*
self
.
tile_h
*
self
.
zoom
+
self
.
display_y
+
sy
return
x
,
y
end
--- Import a map into the current one
-- @param map the map to import
-- @param dx coordinate where to import it in the current map
...
...
This diff is collapsed.
Click to expand it.
game/modules/tome/data/zones/trollmire/zone.lua
+
8
−
8
View file @
58555f98
...
...
@@ -82,13 +82,13 @@ return {
local
Map
=
require
"engine.Map"
local
Particles
=
require
(
"engine.Particles"
)
local
ps
=
{}
ps
[
#
ps
+
1
]
=
Particles
.
new
(
"weather_storm"
,
1
,
{
max_nb
=
5
,
width
=
level
.
map
.
w
*
level
.
map
.
tile_w
,
height
=
level
.
map
.
h
*
level
.
map
.
tile_h
,
speed
=
{
0
.
5
,
1
.
6
},
alpha
=
{
0
.
23
,
0
.
35
},
particle_name
=
"weather/grey_cloud_01"
})
ps
[
#
ps
+
1
]
=
Particles
.
new
(
"weather_storm"
,
1
,
{
max_nb
=
5
,
width
=
level
.
map
.
w
*
level
.
map
.
tile_w
,
height
=
level
.
map
.
h
*
level
.
map
.
tile_h
,
speed
=
{
0
.
5
,
1
.
6
},
alpha
=
{
0
.
23
,
0
.
35
},
particle_name
=
"weather/grey_cloud_02"
})
ps
[
#
ps
+
1
]
=
Particles
.
new
(
"weather_storm"
,
1
,
{
max_nb
=
5
,
width
=
level
.
map
.
w
*
level
.
map
.
tile_w
,
height
=
level
.
map
.
h
*
level
.
map
.
tile_h
,
speed
=
{
0
.
5
,
1
.
6
},
alpha
=
{
0
.
23
,
0
.
35
},
particle_name
=
"weather/grey_cloud_03"
})
ps
[
#
ps
+
1
]
=
Particles
.
new
(
"weather_storm"
,
1
,
{
max_nb
=
5
,
width
=
level
.
map
.
w
*
level
.
map
.
tile_w
,
height
=
level
.
map
.
h
*
level
.
map
.
tile_h
,
speed
=
{
0
.
5
,
1
.
6
},
alpha
=
{
0
.
23
,
0
.
35
},
particle_name
=
"weather/grey_cloud_04"
})
ps
[
#
ps
+
1
]
=
Particles
.
new
(
"weather_storm"
,
1
,
{
max_nb
=
5
,
width
=
level
.
map
.
w
*
level
.
map
.
tile_w
,
height
=
level
.
map
.
h
*
level
.
map
.
tile_h
,
speed
=
{
0
.
5
,
1
.
6
},
alpha
=
{
0
.
23
,
0
.
35
},
particle_name
=
"weather/grey_cloud_05"
})
ps
[
#
ps
+
1
]
=
Particles
.
new
(
"weather_storm"
,
1
,
{
max_nb
=
5
,
width
=
level
.
map
.
w
*
level
.
map
.
tile_w
,
height
=
level
.
map
.
h
*
level
.
map
.
tile_h
,
speed
=
{
0
.
5
,
1
.
6
},
alpha
=
{
0
.
23
,
0
.
35
},
particle_name
=
"weather/grey_cloud_06"
})
ps
[
#
ps
+
1
]
=
Particles
.
new
(
"weather_storm"
,
1
,
{
max_nb
=
5
,
width
=
level
.
map
.
w
*
level
.
map
.
tile_w
,
height
=
level
.
map
.
h
*
level
.
map
.
tile_h
,
speed
=
{
0
.
5
,
1
.
6
},
alpha
=
{
0
.
23
,
0
.
35
},
particle_name
=
"weather/grey_cloud_07"
})
ps
[
#
ps
+
1
]
=
Particles
.
new
(
"weather_storm"
,
1
,
{
max_nb
=
20
,
width
=
level
.
map
.
w
*
level
.
map
.
tile_w
,
height
=
level
.
map
.
h
*
level
.
map
.
tile_h
,
speed
=
{
0
.
5
,
1
.
6
},
alpha
=
{
0
.
23
,
0
.
35
},
particle_name
=
"weather/grey_cloud_01"
})
ps
[
#
ps
+
1
]
=
Particles
.
new
(
"weather_storm"
,
1
,
{
max_nb
=
20
,
width
=
level
.
map
.
w
*
level
.
map
.
tile_w
,
height
=
level
.
map
.
h
*
level
.
map
.
tile_h
,
speed
=
{
0
.
5
,
1
.
6
},
alpha
=
{
0
.
23
,
0
.
35
},
particle_name
=
"weather/grey_cloud_02"
})
ps
[
#
ps
+
1
]
=
Particles
.
new
(
"weather_storm"
,
1
,
{
max_nb
=
20
,
width
=
level
.
map
.
w
*
level
.
map
.
tile_w
,
height
=
level
.
map
.
h
*
level
.
map
.
tile_h
,
speed
=
{
0
.
5
,
1
.
6
},
alpha
=
{
0
.
23
,
0
.
35
},
particle_name
=
"weather/grey_cloud_03"
})
ps
[
#
ps
+
1
]
=
Particles
.
new
(
"weather_storm"
,
1
,
{
max_nb
=
20
,
width
=
level
.
map
.
w
*
level
.
map
.
tile_w
,
height
=
level
.
map
.
h
*
level
.
map
.
tile_h
,
speed
=
{
0
.
5
,
1
.
6
},
alpha
=
{
0
.
23
,
0
.
35
},
particle_name
=
"weather/grey_cloud_04"
})
ps
[
#
ps
+
1
]
=
Particles
.
new
(
"weather_storm"
,
1
,
{
max_nb
=
20
,
width
=
level
.
map
.
w
*
level
.
map
.
tile_w
,
height
=
level
.
map
.
h
*
level
.
map
.
tile_h
,
speed
=
{
0
.
5
,
1
.
6
},
alpha
=
{
0
.
23
,
0
.
35
},
particle_name
=
"weather/grey_cloud_05"
})
ps
[
#
ps
+
1
]
=
Particles
.
new
(
"weather_storm"
,
1
,
{
max_nb
=
20
,
width
=
level
.
map
.
w
*
level
.
map
.
tile_w
,
height
=
level
.
map
.
h
*
level
.
map
.
tile_h
,
speed
=
{
0
.
5
,
1
.
6
},
alpha
=
{
0
.
23
,
0
.
35
},
particle_name
=
"weather/grey_cloud_06"
})
ps
[
#
ps
+
1
]
=
Particles
.
new
(
"weather_storm"
,
1
,
{
max_nb
=
20
,
width
=
level
.
map
.
w
*
level
.
map
.
tile_w
,
height
=
level
.
map
.
h
*
level
.
map
.
tile_h
,
speed
=
{
0
.
5
,
1
.
6
},
alpha
=
{
0
.
23
,
0
.
35
},
particle_name
=
"weather/grey_cloud_07"
})
level
.
foreground_particle
=
ps
end
,
...
...
@@ -96,7 +96,7 @@ return {
local
Map
=
require
"engine.Map"
local
ps
=
level
.
foreground_particle
local
dx
,
dy
=
level
.
map
:
get
TileToScreen
(
0
,
0
)
-- Display at map border, always, so it scrolls with the map
local
dx
,
dy
=
level
.
map
:
get
ScreenUpperCorner
(
)
-- Display at map border, always, so it scrolls with the map
for
j
=
1
,
#
ps
do
for
i
=
1
,
nb_keyframes
do
ps
[
j
]:
update
()
...
...
This diff is collapsed.
Click to expand it.
src/map.c
+
39
−
23
View file @
58555f98
...
...
@@ -729,6 +729,43 @@ static int map_set_scroll(lua_State *L)
return
0
;
}
#define SMOOTH_SCROLL() \
float animdx = 0, animdy = 0; \
int mx = map->mx; \
int my = map->my; \
if (map->move_max) \
{ \
map->move_step += nb_keyframes; \
if (map->move_step >= map->move_max) \
{ \
map->move_max = 0; \
map->oldmx = map->mx; \
map->oldmy = map->my; \
} \
\
if (map->move_max) \
{ \
float adx = (float)map->mx - map->oldmx; \
float ady = (float)map->my - map->oldmy; \
animdx = map->tile_w * (adx * map->move_step / (float)map->move_max - adx); \
animdy = map->tile_h * (ady * map->move_step / (float)map->move_max - ady); \
mx = map->mx + (int)(adx * map->move_step / (float)map->move_max - adx); \
my = map->my + (int)(ady * map->move_step / (float)map->move_max - ady); \
} \
}
static
int
map_get_scroll
(
lua_State
*
L
)
{
map_type
*
map
=
(
map_type
*
)
auxiliar_checkclass
(
L
,
"core{map}"
,
1
);
int
nb_keyframes
=
1
;
SMOOTH_SCROLL
();
lua_pushnumber
(
L
,
-
animdx
);
lua_pushnumber
(
L
,
-
animdy
);
return
2
;
}
#define DO_QUAD(dx, dy, zoom, r, g, b, a) {\
vertices[(*vert_idx)] = (dx); vertices[(*vert_idx)+1] = (dy); \
vertices[(*vert_idx)+2] = map->tile_w * (zoom) + (dx); vertices[(*vert_idx)+3] = (dy); \
...
...
@@ -902,29 +939,7 @@ static int map_to_screen(lua_State *L)
glColorPointer
(
4
,
GL_FLOAT
,
0
,
colors
);
// Smooth scrolling
float
animdx
=
0
,
animdy
=
0
;
int
mx
=
map
->
mx
;
int
my
=
map
->
my
;
if
(
map
->
move_max
)
{
map
->
move_step
+=
nb_keyframes
;
if
(
map
->
move_step
>=
map
->
move_max
)
{
map
->
move_max
=
0
;
// Reset once in place
map
->
oldmx
=
map
->
mx
;
map
->
oldmy
=
map
->
my
;
}
if
(
map
->
move_max
)
{
float
adx
=
(
float
)
map
->
mx
-
map
->
oldmx
;
float
ady
=
(
float
)
map
->
my
-
map
->
oldmy
;
animdx
=
map
->
tile_w
*
(
adx
*
map
->
move_step
/
(
float
)
map
->
move_max
-
adx
);
animdy
=
map
->
tile_h
*
(
ady
*
map
->
move_step
/
(
float
)
map
->
move_max
-
ady
);
mx
=
map
->
mx
+
(
int
)(
adx
*
map
->
move_step
/
(
float
)
map
->
move_max
-
adx
);
my
=
map
->
my
+
(
int
)(
ady
*
map
->
move_step
/
(
float
)
map
->
move_max
-
ady
);
}
}
SMOOTH_SCROLL
();
x
-=
animdx
;
y
-=
animdy
;
...
...
@@ -1084,6 +1099,7 @@ static const struct luaL_reg map_reg[] =
{
"setRemember"
,
map_set_remember
},
{
"setLite"
,
map_set_lite
},
{
"setScroll"
,
map_set_scroll
},
{
"getScroll"
,
map_get_scroll
},
{
"toScreen"
,
map_to_screen
},
{
"toScreenMiniMap"
,
minimap_to_screen
},
{
"setupMiniMapGridSize"
,
map_set_minimap_gridsize
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment