Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .github/workflows/build.yml

This file was deleted.

59 changes: 0 additions & 59 deletions .github/workflows/publish.yml

This file was deleted.

78 changes: 78 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: CI
run-name: ${{ github.ref_type == 'tag' && format('Release "{0}"', github.ref_name) || format('Build "{0}"', github.event.head_commit.message) }}
on: push

jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install SFML
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: build-essential cmake libsfml-dev libudev-dev libopenal-dev libvorbis-dev libflac-dev libx11-dev libxrandr-dev libxcursor-dev libgl-dev libfreetype-dev
- name: Lint
if: ${{ github.ref_type == 'branch' }}
run: cargo fmt --all -- --check

- name: Build
run: cargo build ${{ github.ref_type == 'tag' && '--release' || '' }}

- uses: actions/upload-artifact@v4
if: ${{ github.ref_type == 'tag' }}
with:
name: linux-x64
path: ./target/release/mapgame

build-windows:
runs-on: windows-latest
if: ${{ github.ref_type == 'tag' }}
steps:
- uses: actions/checkout@v4

- name: Download SFML
run: Invoke-WebRequest -OutFile sfml.zip https://github.com/SFML/SFML/releases/download/2.6.2/SFML-2.6.2-windows-vc17-64-bit.zip
- name: Extract SFML
run: Expand-Archive -DestinationPath . .\sfml.zip

- name: Get CMake and Ninja
uses: lukka/get-cmake@latest
with:
cmakeVersion: '3.31'
ninjaVersion: latest
- name: Build
run: cargo build ${{ github.ref_type == 'tag' && '--release' || '' }}
env:
SFML_INCLUDE_DIR: ${{ github.workspace }}\SFML-2.6.2\include
SFML_LIBS_DIR: ${{ github.workspace }}\SFML-2.6.2\lib

- uses: actions/upload-artifact@v4
if: ${{ github.ref_type == 'tag' }}
with:
name: windows-x64
path: ./target/release/mapgame.exe

publish-release:
runs-on: ubuntu-latest
if: ${{ github.ref_type == 'tag' }}
needs:
- build-linux
- build-windows
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: bin
- name: Move artifact files
run: |
mv bin/linux-x64/mapgame mapgame-linux-x64
mv bin/windows-x64/mapgame.exe mapgame-windows-x64.exe
- name: Publish release
uses: softprops/action-gh-release@v2
with:
files: |
mapgame-linux-x64
mapgame-windows-x64.exe
54 changes: 27 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "mapgame"
version = "0.1.0"
version = "0.0.8"
authors = ["Alex Hicks <alex@alexhicks.net>"]
edition = "2021"
edition = "2024"
license = "MIT"
publish = false

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Play strategy, on a map.

1. Install [Rust](https://www.rust-lang.org/tools/install)
2. Install dependencies: `apt install build-essential pkg-config unzip cmake`
- Also see [rust-sfml](https://github.com/jeremyletang/rust-sfml#prerequisites)'s dependencies.
3. Download [SFML 2.6.0](https://www.sfml-dev.org/download/sfml/2.6.0/) and extract it to `./sfml`
a. Also see [rust-sfml](https://github.com/jeremyletang/rust-sfml#prerequisites)'s dependencies.
3. Download [SFML 2.6.2](https://github.com/SFML/SFML/releases/2.6.2) and extract it to `./sfml`
4. Execute `cargo run`

## Todo
Expand Down
8 changes: 5 additions & 3 deletions src/game.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::{config::Config, player::Player, world_map::WorldMap};
use sfml::{
SfResult,
cpp::FBox,
graphics::{Color, Rect, RenderTarget, RenderWindow, View},
system::Vector2f,
window::{mouse::Button, Event, Style},
SfResult,
window::{Event, Style, mouse::Button},
};
use std::error::Error;

Expand All @@ -17,10 +17,12 @@ pub struct Game {

impl Game {
pub fn new(config: Config) -> Result<Game, Box<dyn Error>> {
let world_map = Box::new(WorldMap::new(&config.map)?);
let mut world_map = Box::new(WorldMap::new(&config.map)?);
let mut window = RenderWindow::new((1920, 1080), "mapgame", Style::CLOSE, &Default::default())?;
window.set_framerate_limit(60);
let player = Player::new();
let size = Rect::new(0f32, 0f32, 1920f32, 1080f32);
world_map.on_resize(&size);
Ok(Game {
config,
window,
Expand Down
2 changes: 1 addition & 1 deletion src/geo_drawable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
errors::MapLoadError,
math::{polygon_area, polygon_contains},
};
use geojson::{feature::Id, Feature, JsonValue, Value};
use geojson::{Feature, JsonValue, Value, feature::Id};
use sfml::{
graphics::{Color, PrimitiveType, Rect, RenderStates, Vertex},
system::Vector2f,
Expand Down
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// #![deny(elided_lifetimes_in_paths)]
#[cfg(target_os = "windows")]
#[link(name = "Advapi32")]
unsafe extern "system" {}

pub mod config;
pub mod errors;
Expand Down
Loading