Forum

> > CS2D > Scripts > How to add altitude to maps?
Forums overviewCS2D overview Scripts overviewLog in to reply

English How to add altitude to maps?

23 replies
Page
To the start Previous 1 2 Next To the start

old Re: How to add altitude to maps?

Pagyra
User Off Offline

Quote
I continue experiments with tileset and sprite of shadows and light for tiles ... so it look like tiles height transitions or "altitude".
IMG:https://s015.radikal.ru/i332/1512/8a/4202fbae7406.png

This screenshot is represented by 4 x pixel version of
• tileset of tiles with inside shadow in various configurations (wall/obstacle/floor)
IMG:https://s019.radikal.ru/i621/1512/76/4a3b6720be5d.png

• sprites of tile with outer shadow (2 variants - wall and obstacle)
IMG:https://s013.radikal.ru/i324/1512/77/6890ca5c506a.png

• sprite of highlighted or shaded tile
IMG:https://s003.radikal.ru/i202/1512/29/c83b9f2cdf02.png
edited 2×, last 29.12.15 02:12:34 pm

old Re: How to add altitude to maps?

Zeik
User Off Offline

Quote
You need a Z variable for every (x,y) position (a map) and for every player, and change it everytime a player moves between different heights.

If you want to automatically generate a (x,y,z) map from the editor's map file, then you need to decrypt it first, and I don't know if we are able to do so. Never tried.

old Re: How to add altitude to maps?

xNir
User Off Offline

Quote
Have to be tested for performance issues:

IMG:https://zupimages.net/up/16/20/nk6a.bmp

Tileset

Create a small map and try this way:

Instead of using always hook you'll have to keep in memory the previous positions of everybody. Moreover, you'll need to customize the falling issue and the loading of tiles height.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
local playersZ = {} --// Height of players
local playersPos = {} --// {tileX, tileY}
local tiles = {} --// Height
local tilecount = map("tilecount")

for i=0,tilecount do
	if (i % 3 == 0) then
		tiles[i] = 0
	elseif (i % 3 == 1) then
		tiles[i] = -1
	else
		tiles[i] = 1
	end
end

--// Init height 
for i=1,32 do
	playersZ[i] = 0
	playersPos[i] = {0, 0}
end

addhook("spawn", "spawnHook")
function spawnHook(id)
	playersPos[id] = {player(id, "tilex"), player(id, "tiley")}
	playersZ[id] = tiles[tile(player(id, "tilex"), player(id, "tiley"), "frame")]
end

--// A player looses damage on fall
addhook("movetile", "moveTileHook")
function moveTileHook(id, x, y)
	local tileHeight = tiles[tile(x, y, "frame")]
	local playerHeight = playersZ[id]

	local prevX = playersPos[id][1] * 32
	local prevY = playersPos[id][2] * 32

	if (playerHeight < tileHeight) then
		parse("setpos "..id.." "..(prevX+16).." "..(prevY+16)) --// center the player
	elseif (playerHeight > tileHeight) then
		parse("slap "..id)
		playersPos[id] = {x, y}
		playersZ[id] = tileHeight
	else
		playersPos[id] = {x, y}
	end
end
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview