forked from carstene1ns/solarus-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add optional sprite parameters to entity:overlaps()
Closes solarus-games#1159.
- Loading branch information
1 parent
e81a4ab
commit b6e2914
Showing
8 changed files
with
159 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
tests/testing_quest/data/maps/bugs/1159_entity_overlaps_sprites.dat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
properties{ | ||
x = 0, | ||
y = 0, | ||
width = 320, | ||
height = 240, | ||
min_layer = 0, | ||
max_layer = 2, | ||
tileset = "castle", | ||
} | ||
|
||
tile{ | ||
layer = 0, | ||
x = 0, | ||
y = 0, | ||
width = 320, | ||
height = 240, | ||
pattern = "3", | ||
} | ||
|
||
destination{ | ||
name = "destination", | ||
layer = 0, | ||
x = 24, | ||
y = 29, | ||
direction = 0, | ||
} | ||
|
||
custom_entity{ | ||
name = "custom", | ||
layer = 0, | ||
x = 48, | ||
y = 29, | ||
width = 16, | ||
height = 16, | ||
direction = 0, | ||
sprite = "16x16", | ||
} | ||
|
42 changes: 42 additions & 0 deletions
42
tests/testing_quest/data/maps/bugs/1159_entity_overlaps_sprites.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
local map = ... | ||
local game = map:get_game() | ||
|
||
game:set_ability("sword", 1) | ||
|
||
function map:on_opening_transition_finished() | ||
|
||
-- Give two sprites to the custom entity: a main one and a shadow. | ||
-- The sword sprite of the hero will overlap the main one but not the shadow. | ||
|
||
local custom_main_sprite = custom:get_sprite() | ||
assert(custom_main_sprite ~= nil) | ||
local custom_shadow_sprite = custom:create_sprite("entities/shadow") | ||
assert(custom_shadow_sprite ~= nil) | ||
custom_shadow_sprite:set_animation("small") | ||
|
||
game:simulate_command_pressed("attack") | ||
sol.timer.start(map, 500, function() | ||
assert(not hero:overlaps(custom)) | ||
assert(not hero:overlaps(custom, overlapping)) | ||
assert(hero:overlaps(custom, "sprite")) | ||
|
||
local tunic_sprite = hero:get_sprite("tunic") | ||
assert(tunic_sprite ~= nil) | ||
local sword_sprite = hero:get_sprite("sword") | ||
assert(sword_sprite ~= nil) | ||
|
||
assert(not hero:overlaps(custom, "sprite", tunic_sprite, custom_main_sprite)) | ||
assert(not hero:overlaps(custom, "sprite", tunic_sprite, custom_shadow_sprite)) | ||
assert(hero:overlaps(custom, "sprite", sword_sprite, custom_main_sprite)) | ||
assert(not hero:overlaps(custom, "sprite", sword_sprite, custom_shadow_sprite)) | ||
|
||
assert(not hero:overlaps(custom, "sprite", tunic_sprite, nil)) | ||
assert(not hero:overlaps(custom, "sprite", tunic_sprite)) | ||
assert(hero:overlaps(custom, "sprite", sword_sprite, nil)) | ||
assert(hero:overlaps(custom, "sprite", sword_sprite)) | ||
assert(hero:overlaps(custom, "sprite", nil, custom_main_sprite)) | ||
assert(not hero:overlaps(custom, "sprite", nil, custom_shadow_sprite)) | ||
|
||
sol.main.exit() | ||
end) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters