Skip to content

Commit

Permalink
Merge pull request #5 from wojciechmadry/fix_resolution
Browse files Browse the repository at this point in the history
Fix resolution
  • Loading branch information
wojciechmadry authored Aug 18, 2023
2 parents a779412 + 5ca371c commit 5177097
Show file tree
Hide file tree
Showing 56 changed files with 583 additions and 557 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/docker_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Dockerfile build

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'

jobs:

build:

runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --file Dockerfile --tag kulki_docker:$(date +%s)
45 changes: 31 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,53 @@ if(UNIX)
find_package(Threads REQUIRED)
endif(UNIX)

include_directories(src)

# Set path to sfml folder
set(SFML_PATH /home/wojtek/Desktop/GIT/SFML-2.5.1/)
set(INCLUDE ${SFML_PATH}/include/)
set(LIB ${SFML_PATH}/lib/)
if(UNIX)
find_package(SFML COMPONENTS graphics window system REQUIRED)
endif()

include_directories(${INCLUDE})
link_directories(${LIB})
include_directories(
src/BabelLib
include
)

add_subdirectory(src)
file(GLOB_RECURSE SRC_FILES src/function/*.cpp src/object/*.cpp)
file(GLOB_RECURSE HEADERS_FILES include/*.hpp include/*.h)

if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
add_definitions(-D__32BITVERSION__)
else()
add_definitions(-D__64BITVERSION__)
endif()



add_executable(Kulki
#WIN32
main.cpp
)
${SRC_FILES}
)

target_compile_options(Kulki PRIVATE -O3 -Wextra -Werror -W -Wshadow -Wdouble-promotion -Wformat=2 -Wundef -fno-common -Wconversion -pedantic -Wall)

if(UNIX)
target_link_libraries(Kulki PUBLIC Threads::Threads)
endif(UNIX)

target_link_libraries(Kulki PRIVATE ${LIBRARIES})
target_link_libraries(Kulki PRIVATE
sfml-window
sfml-graphics
sfml-system
)

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/ball_texture
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/font
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

add_custom_target(
clangformat
COMMAND /usr/bin/clang-format
-i
${SRC_FILES}
${HEADERS_FILES}
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
)

27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM ubuntu:22.04

WORKDIR /ws

RUN apt update \
&& apt upgrade -y\
&& apt install -y\
libsfml-dev \
cmake \
ninja-build \
clang \
git

ENV CC=clang
ENV CXX=clang++
ENV BRANCH=master

RUN git clone https://github.com/wojciechmadry/Kulki.git \
&& cd Kulki \
&& git checkout ${BRANCH} \
&& git submodule init \
&& git submodule update \
&& mkdir -p build \
&& cd build \
&& cmake -GNinja ../ \
&& ninja

92 changes: 92 additions & 0 deletions font/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
Copyright (c) 2020 XMind ltd. All Rights Reserved

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL

-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 02 January 2020
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION AND CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file added font/NeverMindHand/ttf/NeverMindHand-Bold.ttf
Binary file not shown.
Binary file added font/NeverMindHand/ttf/NeverMindHand-DemiBold.ttf
Binary file not shown.
Binary file not shown.
Binary file added font/NeverMindHand/ttf/NeverMindHand-Light.ttf
Binary file not shown.
Binary file added font/NeverMindHand/ttf/NeverMindHand-Medium.ttf
Binary file not shown.
Binary file added font/NeverMindHand/ttf/NeverMindHand-Regular.ttf
Binary file not shown.
Binary file added font/NeverMindHand/ttf/NeverMindHand-Thin.ttf
Binary file not shown.
65 changes: 65 additions & 0 deletions font/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

![](sources/cover.png)

# The NeverMind Font Family

[NeverMind](https://www.behance.net/gallery/89046307/NeverMind) is the brand font of Xmind. It is a font family based on the logotype used and designed by [Xmind](https://www.xmind.net/). It is geometric and humanist font, modern and friendly, and can be used for all types of communication. It is a available in 10 weights (100-1000) and supports 109 languages including German, French, Greek and Russian.

This font family currently includes one basic typeface and more than ten different fonts in various styles, including round, handwritten, serif, slab and so on.

## Font Details

* **All Fonts**

The font family contains all following fonts:

[**NeverMind**](https://www.behance.net/gallery/89046307/NeverMind)

**NeverMind family**

NeverMind UltraCondensed
NeverMind ExtraCondensed
NeverMind Condensed
NeverMind SemiCondensed
NeverMind SemiExtended
NeverMind Extended
NeverMind ExtraExtended
NeverMind UltraExtended
NeverMind Headline

NeverMind Compact
NeverMind Display
NeverMind Hand
NeverMind Handwritting
NeverMind Rounded Mono
NeverMind Mono
NeverMind Rounded
NeverMind semi-serif
NeverMind New Serif
NeverMind Slab
NeverMind Bauhaus
NeverMind Pixel


* **Supported languages**

Most Latin languages, including, but not limited to, Afrikaans, Basque, Breton, Catalan, Danish, Dutch, English, Finnish, French, Gaelic, German, Icelandic, Indonesian, Irish, Italian, Norwegian, Portuguese, Saami, Spanish, Swahili, Swedish, russian and more over 100 languages.

Note: Catalan is not strictly supported by Latin Std fonts because of the Ldot. Dutch is not strictly supported by Latin Std fonts because of the IJ glyph. Except for NeverMind, other fonts do not support Greek, Russian, icons, nor a series of opentye attributes.

* **Font designer**

The fonts were designed by [Xmind Designer Team](https://www.zcool.com.cn/u/18786155).

## Styles

![](sources/font-family.png)

## Usage

You can simply download fonts resource files and install to use.

## LICENSE

[SIL Open Font License.](LICENSE)

File renamed without changes.
File renamed without changes.
77 changes: 77 additions & 0 deletions include/drawer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//
// Created by Wojtek on 20.11.2020.
//

#ifndef KULKI_DRAWER_HPP
#define KULKI_DRAWER_HPP

#include "map.hpp"
#include "resource.hpp"

void generate_started_object(ResourceHolder<sf::Drawable> &Resource,
const sf::Font &font, uint16_t record,
uint16_t score, float width,
float height) noexcept;

sf::RectangleShape
make_rectangle(sf::Vector2f Size, sf::Vector2f Position, sf::Color Color,
float OutlineThick = 0.0f,
sf::Color OutlineColor = sf::Color::Transparent) noexcept;

class GLOBAL {
public:
static void INIT(ResourceHolder<sf::Drawable> &Resource,
const sf::Font &sfFont,
std::pair<uint16_t, uint16_t> RECORDS, float width,
float height) noexcept;
static void UPDATE_RESOLUTION(ResourceHolder<sf::Drawable> &Resource,
float width, float height);

[[nodiscard]] static float get_white_box_size() noexcept;

[[nodiscard]] static bool BALL_TEXTURE() noexcept;

[[nodiscard]] static bool BACKGROUND_TEXTURE() noexcept;

[[nodiscard]] static bool RED_BOX_TEXTURE() noexcept;

private:
inline static bool m_BALL_TEXTURE =
false; // Texture to ball is load? //NOLINT
inline static bool m_BG_TEXTURE =
false; // Texture background is load ? //NOLINT
inline static bool m_RED_BOX_TEXTURE =
false; // Red box texture is load ? //NOLINT

inline static float a{0.0f}; // Side length of white box
inline static float radius{0.0f}; // Radius of circle

static void calculate_static_vars(float width, float height);
static void create_ball(ResourceHolder<sf::Drawable> &Resource);
static void create_white_box(ResourceHolder<sf::Drawable> &Resource);
static void create_map_before_grid(ResourceHolder<sf::Drawable> &Resource,
float width, float height);
static void update_ball_texture(ResourceHolder<sf::Drawable> &Resource);
static void update_redbox_texture(ResourceHolder<sf::Drawable> &Resource);
static void update_background_texture(ResourceHolder<sf::Drawable> &Resource,
float width, float height);
static void update_started_objects(ResourceHolder<sf::Drawable> &Resource,
float width, float height);
};

void draw_window(sf::RenderWindow &window, map &Map,
ResourceHolder<sf::Drawable> &Resource);

// Simplify sf::Text
sf::Text make_text(const std::string &text, const sf::Vector2f &pos,
sf::Color color, uint32_t size, const sf::Font &font);

// Scales cor on screen to cor on grid
// ex.: cor can be position on screen {320, 15}
// and return value is cor {x, y} on grid
// cor = {320, 15} or cor {325, 15} etc. will show the same position {x, y} on
// grid Every square of grid is 70x70 pixel.
std::pair<int8_t, int8_t> MapCorToGrid(sf::Vector2<float> cor, float width,
float height) noexcept;

#endif // KULKI_DRAWER_HPP
4 changes: 1 addition & 3 deletions src/function/load/load.hpp → include/load.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
#ifndef KULKI_LOAD_HPP
#define KULKI_LOAD_HPP

#include "object/map/map.hpp"
#include "map.hpp"
#include <SFML/Graphics/Font.hpp>
#include <cstdint>
#include <string>

// load font
sf::Font load_font(const std::string &path);

std::pair<uint32_t, uint32_t> load_resolution() noexcept;

uint32_t load_fps() noexcept;

// Check for encrypt record in file
Expand Down
2 changes: 1 addition & 1 deletion src/object/map/map.hpp → include/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef KULKI_MAP_HPP
#define KULKI_MAP_HPP

#include "object/ball/ball.hpp"
#include "ball.hpp"
#include <array>
#include <cstdint>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#ifndef KULKI_MOUSE_CLICK_EVENT_HPP
#define KULKI_MOUSE_CLICK_EVENT_HPP

#include "function/thread/thread_wrapper.hpp"
#include "object/red_box/red_box.hpp"
#include "red_box.hpp"
#include "thread_wrapper.hpp"

namespace MOUSE {
void left_click(Thread &thread, sf::RenderWindow &window,
Expand Down
Loading

0 comments on commit 5177097

Please sign in to comment.