Giter Site home page Giter Site logo

wg-romank / alien-attack Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 463 KB

Elm/WebGl example for simple arcade game

Home Page: https://wg-romank.github.io/alien-attack/

Elm 96.29% Makefile 0.94% HTML 2.78%
webgl elm functional-programming game-development arcade-game

alien-attack's Introduction

Alien Attack arcade-style game

This is a tech test / demo for working with WegbGL from Elm programming language.

Main motivation behind this project was to explore functional programming techniques and how well they would fit with game development.

This repo implements basic concepts like working with textures, defining GLSL shaders for WebGL and doing simple math to run game simulation as well as minor HUD bits and scaling for different screens.

Implementation is rather naive and could be improved in terms of efficiency by utilizing common space segregation data structures like VP or Octo trees. (At the moment collision detection is done by doing all-vs-all objects match which would obviously not work for any decently sized game).

Turns out functional style and immutable data structures are nice fit for the task, just look at the main game loop

gameLoop: Float -> GameState -> GameState
gameLoop timeDelta state =
        state
            |> performPlayerAction state.userInput
            |> moveRounds timeDelta
            |> performEnemiesActions timeDelta
            |> moveEnemyRounds timeDelta
            |> updateTimesSinceSpawned timeDelta
            |> playerMoveFromCourse timeDelta
            |> moveBackground
            |> enemySpawn

Also HTML5 programming model for working with animation that is using time delta would be familiar for people with experience working with popular game engines like Godot and Unity.

In the end there are maybe simplier and faster ways to implement similar functionality using one of popular game engines. Current approach might be interesting for person familiar with web or functional programming or both. Main benefit here is explicit state management. Since all data structures are immutable, any new updates need to go through explicit queuing which helps to reason about the logic. (See user input handling or random generation)

Game is hosted as static page at the url in the barcode.

[https://wg-romank.github.io/alien-attack/]

alien-attack's People

Contributors

wg-romank avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.