Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add some more sprites to S14X. Fiddle with the parallax

  • Loading branch information...
commit 49c43458615a307e482000e4d1eb674ac4b82adf 1 parent b359041
Luke Benstead authored

Showing 35 changed files with 48 additions and 12 deletions. Show diff stats Hide diff stats

  1. +3 0  CMakeLists.txt
  2. +19 0 k4x/chapters/splash_chapter.h
  3. +16 10 k4x/chapters/title_chapter.cpp
  4. +1 1  k4x/chapters/title_chapter.h
  5. +1 0  s14x.files
  6. +8 1 s14x/main.cpp
  7. BIN  s14x/resources/centbold.ttf
  8. BIN  s14x/resources/splash/logo_0.png
  9. BIN  s14x/resources/splash/logo_1.png
  10. BIN  s14x/resources/splash/logo_10.png
  11. BIN  s14x/resources/splash/logo_11.png
  12. BIN  s14x/resources/splash/logo_12.png
  13. BIN  s14x/resources/splash/logo_13.png
  14. BIN  s14x/resources/splash/logo_14.png
  15. BIN  s14x/resources/splash/logo_15.png
  16. BIN  s14x/resources/splash/logo_16.png
  17. BIN  s14x/resources/splash/logo_17.png
  18. BIN  s14x/resources/splash/logo_18.png
  19. BIN  s14x/resources/splash/logo_19.png
  20. BIN  s14x/resources/splash/logo_2.png
  21. BIN  s14x/resources/splash/logo_20.png
  22. BIN  s14x/resources/splash/logo_21.png
  23. BIN  s14x/resources/splash/logo_22.png
  24. BIN  s14x/resources/splash/logo_23.png
  25. BIN  s14x/resources/splash/logo_24.png
  26. BIN  s14x/resources/splash/logo_3.png
  27. BIN  s14x/resources/splash/logo_4.png
  28. BIN  s14x/resources/splash/logo_5.png
  29. BIN  s14x/resources/splash/logo_6.png
  30. BIN  s14x/resources/splash/logo_7.png
  31. BIN  s14x/resources/splash/logo_8.png
  32. BIN  s14x/resources/splash/logo_9.png
  33. BIN  s14x/resources/title/background_0.png
  34. BIN  s14x/resources/title/background_1.png
  35. BIN  s14x/resources/title/background_2.png
3  CMakeLists.txt
@@ -8,6 +8,7 @@ SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules/")
8 8 FIND_PACKAGE(KGLT REQUIRED)
9 9 FIND_PACKAGE(KAZMATH REQUIRED)
10 10 FIND_PACKAGE(Boost COMPONENTS system filesystem thread date_time regex REQUIRED)
  11 +FIND_PACKAGE(Freetype REQUIRED)
11 12
12 13 FIND_PACKAGE(PkgConfig)
13 14 PKG_CHECK_MODULES(SIGC QUIET sigc++-2.0)
@@ -24,6 +25,7 @@ INCLUDE_DIRECTORIES(
24 25 ${SDL_INCLUDE_DIRS}
25 26 ${GL_INCLUDE_DIRS}
26 27 ${GLU_INCLUDE_DIRS}
  28 + ${FREETYPE_INCLUDE_DIRS}
27 29 )
28 30
29 31 LINK_LIBRARIES(
@@ -41,6 +43,7 @@ LINK_LIBRARIES(
41 43 ${GLU_LIBRARIES}
42 44
43 45 ${SIGC_LIBRARIES}
  46 + ${FREETYPE_LIBRARY}
44 47 )
45 48
46 49 ADD_SUBDIRECTORY(k4x)
19 k4x/chapters/splash_chapter.h
... ... @@ -0,0 +1,19 @@
  1 +#ifndef SPLASH_CHAPTER_H
  2 +#define SPLASH_CHAPTER_H
  3 +
  4 +#include "chapter.h"
  5 +
  6 +namespace k4x {
  7 +
  8 +class SplashChapter : Chapter {
  9 +public:
  10 + SplashChapter();
  11 +
  12 + static SplashChapter::ptr create() {
  13 + return SplashChapter::ptr(new SplashChapter());
  14 + }
  15 +};
  16 +
  17 +}
  18 +
  19 +#endif // SPLASH_CHAPTER_H
26 k4x/chapters/title_chapter.cpp
@@ -2,6 +2,7 @@
2 2 #include "../engine.h"
3 3 #include "../chapter_manager.h"
4 4
  5 +#include "kglt/ui/shortcuts.h"
5 6 #include "kglt/kazbase/logging/logging.h"
6 7
7 8 namespace k4x {
@@ -28,12 +29,15 @@ void TitleChapter::add_sprite(const std::string& sprite_image, SpritePosition po
28 29 }
29 30 }
30 31
31   -void TitleChapter::set_background_image(const std::string& background_image) {
32   - background_image_path_ = background_image;
  32 +void TitleChapter::add_background_image(const std::string& background_image) {
  33 + L_DEBUG("Loading background image from: " + background_image);
  34 + kglt::Scene& scene = manager().engine().window().scene();
  35 + scene.background().add_layer(background_image);
  36 + L_DEBUG("Background loaded");
33 37 }
34 38
35 39 void TitleChapter::enable_background_scrolling(bool value) {
36   - if(background_image_path_.empty()) return;
  40 + //if(background_image_path_.empty()) return;
37 41
38 42 background_scrolling_enabled_ = value;
39 43 if(!value && scroll_connection_) {
@@ -49,13 +53,13 @@ void TitleChapter::on_prepare_start() {
49 53 kglt::Window& window = manager().engine().window();
50 54 kglt::Scene& scene = window.scene();
51 55
52   - if(!background_image_path_.empty()) {
53   - L_DEBUG("Loading background image from: " + background_image_path_);
54   - scene.background().add_layer(background_image_path_);
55   - L_DEBUG("Background loaded");
56   - }
  56 + kglt::ui::Label& label = kglt::ui::return_new_label(scene);
  57 + label.set_position(0.75, 0.025);
  58 + label.background().set_visible(false);
  59 + label.border().set_visible(false);
  60 + label.set_text(u8"\u00a9 SEGA 1991");
57 61
58   - /*
  62 + /*
59 63 if(!title_music_path_.empty()) {
60 64 kalt::System& system = manager().engine().sound();
61 65 title_music_ = system.new_track();
@@ -96,7 +100,9 @@ bool TitleChapter::scroll_background() {
96 100 return false;
97 101 }
98 102
99   - window.scene().background().layer(0).scroll_x(0.1 * window.delta_time());
  103 + window.scene().background().layer(0).scroll_x(0.05 * window.delta_time());
  104 + window.scene().background().layer(1).scroll_x(0.06 * window.delta_time());
  105 + window.scene().background().layer(2).scroll_x(0.07 * window.delta_time());
100 106 return true;
101 107 }
102 108
2  k4x/chapters/title_chapter.h
@@ -26,7 +26,7 @@ class TitleChapter : public Chapter {
26 26 }
27 27
28 28 void add_demo(const std::string& demo_video);
29   - void set_background_image(const std::string& background_image);
  29 + void add_background_image(const std::string& background_image);
30 30 void add_sprite(const std::string& sprite, SpritePosition position);
31 31
32 32 void enable_background_scrolling(bool value=true);
1  s14x.files
@@ -20,3 +20,4 @@ s14x/CMakeLists.txt
20 20 s14x/main.cpp
21 21 k4x/chapters/boot_chapter.h
22 22 k4x/chapters/boot_chapter.cpp
  23 +k4x/chapters/splash_chapter.h
9 s14x/main.cpp
@@ -15,8 +15,15 @@ int main(int argc, char* argv[]) {
15 15
16 16 k4x::Engine engine(argc, argv);
17 17
  18 + kglt::FontID fid = engine.window().scene().new_font();
  19 + kglt::Font& f = engine.window().scene().font(fid);
  20 + f.initialize("s14x/resources/centbold.ttf", 12);
  21 + engine.window().scene().ui().set_default_font_id(fid);
  22 +
18 23 engine.window().set_title("Sonic 1 4X");
19   - engine.title().set_background_image("s14x/resources/title/background.png"); //Give the title screen a background
  24 + engine.title().add_background_image("s14x/resources/title/background_0.png"); //Give the title screen a background
  25 + engine.title().add_background_image("s14x/resources/title/background_1.png");
  26 + engine.title().add_background_image("s14x/resources/title/background_2.png");
20 27 engine.title().add_sprite("s14x/resources/title/halo.png", k4x::SPRITE_POSITION_CENTRED);
21 28
22 29 /*
BIN  s14x/resources/centbold.ttf
Binary file not shown
BIN  s14x/resources/splash/logo_0.png
BIN  s14x/resources/splash/logo_1.png
BIN  s14x/resources/splash/logo_10.png
BIN  s14x/resources/splash/logo_11.png
BIN  s14x/resources/splash/logo_12.png
BIN  s14x/resources/splash/logo_13.png
BIN  s14x/resources/splash/logo_14.png
BIN  s14x/resources/splash/logo_15.png
BIN  s14x/resources/splash/logo_16.png
BIN  s14x/resources/splash/logo_17.png
BIN  s14x/resources/splash/logo_18.png
BIN  s14x/resources/splash/logo_19.png
BIN  s14x/resources/splash/logo_2.png
BIN  s14x/resources/splash/logo_20.png
BIN  s14x/resources/splash/logo_21.png
BIN  s14x/resources/splash/logo_22.png
BIN  s14x/resources/splash/logo_23.png
BIN  s14x/resources/splash/logo_24.png
BIN  s14x/resources/splash/logo_3.png
BIN  s14x/resources/splash/logo_4.png
BIN  s14x/resources/splash/logo_5.png
BIN  s14x/resources/splash/logo_6.png
BIN  s14x/resources/splash/logo_7.png
BIN  s14x/resources/splash/logo_8.png
BIN  s14x/resources/splash/logo_9.png
BIN  s14x/resources/title/background_0.png
BIN  s14x/resources/title/background_1.png
BIN  s14x/resources/title/background_2.png

0 comments on commit 49c4345

Please sign in to comment.
Something went wrong with that request. Please try again.