1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # Client `Assets` and client-only services on game elements
16 module assets
is no_warning
("attr-in-refinement")
25 redef fun load_image
(path
)
33 redef class FeatureRule
34 # Images of different alternatives
35 var images
: Array[Image]
39 # Image of the base tank structure, at different health level
40 var base_images
: Array[Image]
43 var turret_image
: Image
47 # Rotation angle of this feature
48 var angle
: Float = pi
.rand
50 # Index within `rule.images` of the image of this instance
51 var image_index
: Int = rule
.images
.length
.rand
is lazy
54 # Collection of assets
57 # Images from the `art/drawing.svg` file
58 var drawing
= new DrawingImages
59 init do drawing
.load_all
(app
)
62 var turret_fire
= new Sound("sounds/turret_fire.wav")
64 # Turret is ready to fire sound
65 var turret_ready
= new Sound("sounds/turret_ready.mp3")
67 # Associate images to the `story` rules
68 fun assign_images_to_story
(story
: Story)
70 story
.tree
.images
= drawing
.trees
71 story
.rock
.images
= drawing
.rock
72 story
.debris
.images
= drawing
.debris
74 for tank
in story
.tanks
do
75 tank
.base_images
= drawing
.tank_hit
76 tank
.turret_image
= drawing
.turret
79 story
.health
.images
= [drawing
.health
]