Skip to content

Commit b8a68b2

Browse files
committed
forgot to add files
1 parent 57dbfb3 commit b8a68b2

File tree

2 files changed

+167
-0
lines changed

2 files changed

+167
-0
lines changed

games/HOME/bits/WorldResources.cc

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#include "WorldResources.h"
2+
3+
#include <gf2/core/Property.h>
4+
5+
#include <gf2/audio/Music.h>
6+
#include <gf2/audio/Sound.h>
7+
#include <gf2/framework/BundleBuilder.h>
8+
#include <gf2/graphics/RichMap.h>
9+
10+
#include "GameHub.h"
11+
#include "SupplyType.h"
12+
13+
namespace home {
14+
15+
WorldResources::WorldResources()
16+
{
17+
using namespace gf::literals;
18+
19+
map.filename = "map/Map.tmx";
20+
21+
main_theme_music.filename = "sounds/main_theme.ogg";
22+
main_theme_music.data.type = gf::AudioSourceType::Music;
23+
main_theme_music.data.loop = true;
24+
25+
jet_engine_sound.filename = "sounds/jet_engine.ogg";
26+
27+
mining_sound.filename = "sounds/mining.ogg";
28+
mining_sound.data.loop = true;
29+
oxygen_sound.filename = "sounds/o2_filling.ogg";
30+
oxygen_sound.data.loop = true;
31+
32+
breath_low_o2_sound.filename = "sounds/breath_low_o2.ogg";
33+
victory_sound.filename = "sounds/win.ogg";
34+
death_sound.filename = "sounds/death.ogg";
35+
36+
hero_animations.textures = { "images/player_animations.png", "images/player_death.png" };
37+
38+
gf::AnimationData animation;
39+
animation.properties = gf::AnimationProperties::Loop;
40+
animation.color = gf::White;
41+
int animation_index = 0;
42+
43+
const gf::Id animation_ids[] = {
44+
"move_west"_id,
45+
"move_north_west"_id,
46+
"move_north"_id,
47+
"move_north_east"_id,
48+
"move_east"_id,
49+
"move_south_east"_id,
50+
"move_south_west"_id,
51+
"pause_west"_id,
52+
"pause_north_west"_id,
53+
"pause_north"_id,
54+
"pause_north_east"_id,
55+
"pause_east"_id,
56+
"pause_south_east"_id,
57+
"pause_south_west"_id,
58+
"south"_id,
59+
"harvest_north_west"_id,
60+
"harvest_north_east"_id,
61+
"harvest_south_east"_id,
62+
"harvest_south_west"_id,
63+
};
64+
65+
for (auto id : animation_ids) {
66+
animation.frames.clear();
67+
animation.add_tileset(0, gf::vec(22, 19), gf::seconds(1.0f / 30.f), 22, animation_index * 22);
68+
hero_animations.data.animations.emplace(id, animation);
69+
++animation_index;
70+
}
71+
72+
animation.properties = gf::None;
73+
animation.frames.clear();
74+
animation.add_tileset(1, gf::vec(22, 4), gf::seconds(1.0f / 30.f), 83, 0);
75+
animation.add_tileset(1, gf::vec(22, 4), gf::seconds(60.0f * 60.0f * 24.0f * 10000.0f), 1, 83);
76+
hero_animations.data.animations.emplace("death"_id, animation);
77+
78+
crosshair.texture = "crosshair.png";
79+
80+
constexpr float ResourceUnitX = 1.0f / 7.0f;
81+
constexpr float ResourceUnitY = 1.0f / 5.0f;
82+
83+
energy_sprite.texture = "map/ResourceSet.png";
84+
energy_sprite.data.texture_region = gf::RectF::from_position_size({ 0 * ResourceUnitX, 0.0f }, { ResourceUnitX, ResourceUnitY });
85+
metal_sprite.texture = "map/ResourceSet.png";
86+
metal_sprite.data.texture_region = gf::RectF::from_position_size({ 1 * ResourceUnitX, 0.0f }, { ResourceUnitX, ResourceUnitY });
87+
oxygen_sprite.texture = "map/ResourceSet.png";
88+
oxygen_sprite.data.texture_region = gf::RectF::from_position_size({ 2 * ResourceUnitX, 0.0f }, { ResourceUnitX, ResourceUnitY });
89+
90+
backpack_icon.texture = "images/inventory_icon.png";
91+
oxygen_icon.texture = "images/oxygen_icon.png";
92+
oxygen_icon.data.color = gf::darker(to_color(SupplyType::Oxygen));
93+
}
94+
95+
gf::ResourceBundle WorldResources::bundle(GameHub* hub)
96+
{
97+
gf::BundleBuilder builder(hub);
98+
99+
builder.add_in_bundle(map);
100+
101+
builder.add_in_bundle(main_theme_music);
102+
103+
builder.add_in_bundle(jet_engine_sound);
104+
builder.add_in_bundle(mining_sound);
105+
builder.add_in_bundle(oxygen_sound);
106+
builder.add_in_bundle(breath_low_o2_sound);
107+
builder.add_in_bundle(victory_sound);
108+
builder.add_in_bundle(death_sound);
109+
110+
builder.add_in_bundle(hero_animations);
111+
112+
builder.add_in_bundle(crosshair);
113+
builder.add_in_bundle(energy_sprite);
114+
builder.add_in_bundle(metal_sprite);
115+
builder.add_in_bundle(oxygen_sprite);
116+
117+
builder.add_in_bundle(backpack_icon);
118+
builder.add_in_bundle(oxygen_icon);
119+
120+
return builder.make_bundle();
121+
}
122+
123+
}

games/HOME/bits/WorldResources.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#ifndef HOME_WORLD_DATA_H
2+
#define HOME_WORLD_DATA_H
3+
4+
#include <gf2/core/ActionSettings.h>
5+
#include <gf2/core/AnimationData.h>
6+
#include <gf2/core/AudioSourceData.h>
7+
#include <gf2/core/ResourceBundle.h>
8+
#include <gf2/core/RichMapResource.h>
9+
#include <gf2/core/SpriteData.h>
10+
#include <gf2/core/TextData.h>
11+
12+
namespace home {
13+
class GameHub;
14+
15+
struct WorldResources {
16+
WorldResources();
17+
18+
gf::ResourceBundle bundle(GameHub* hub);
19+
20+
gf::RichMapResource map;
21+
22+
gf::AudioSourceResource main_theme_music;
23+
24+
gf::AudioSourceResource jet_engine_sound;
25+
gf::AudioSourceResource mining_sound;
26+
gf::AudioSourceResource oxygen_sound;
27+
gf::AudioSourceResource breath_low_o2_sound;
28+
gf::AudioSourceResource victory_sound;
29+
gf::AudioSourceResource death_sound;
30+
31+
gf::AnimationGroupResource hero_animations;
32+
33+
gf::SpriteResource crosshair;
34+
gf::SpriteResource energy_sprite;
35+
gf::SpriteResource metal_sprite;
36+
gf::SpriteResource oxygen_sprite;
37+
38+
gf::SpriteResource backpack_icon;
39+
gf::SpriteResource oxygen_icon;
40+
};
41+
42+
}
43+
44+
#endif // HOME_WORLD_DATA_H

0 commit comments

Comments
 (0)