Code Monkey home page Code Monkey logo

ol-games's Introduction

ol-games

One hand, many games use maps as playground and some are based on a map. On the other hand, OpenLayers is a high-performance, feature-packed library for creating interactive maps on the web.

This project aims to test and add game mechanisms within Openlayers (ol).

It is by no means a complete game or complete game engine but you should find some stuff to devleopp game on a map with Openlayers.

View live examples online!

Dependencies

This project uses Openlayers and ol-ext. Hexagnol grid concepts developped in the Red Blob Games.

Materials mainly comes from the FreeSound project and OpenGameArt.

Openlayers

OpenLayers makes it easy to put a dynamic map in any web page.

  • It can display map tiles, vector data and markers loaded from any source.
  • Leverages Canvas 2D, WebGL, and all the latest greatness from HTML5. Mobile support out of the box.
  • Implements animations mecanisms and the postcompose hook allows to intervene with the OpenLayers rendering process to draw onto the canvas context. A postcompose listener is called for every rendering frame and is the perfect place to implement animations.
    Just look at the Openlayers example page to see what's up.
  • Render objects over the map (vector features) with styling functionnalities.
  • Add interactions widgets to the map (controls, overlays) to interact with your maps.
  • Actually already uses a 2D spatial index R-Tree to perform spatial queries very efficiently.
  • Pixel-based hit-detection
  • Exposes an API for drawing geometries and features to the output canvas

ol-games

Here are some of the features I'm working on in this repository.

Hex map

A hexagonal map or hex map is a game board design commonly used in wargames of all scales. The map is subdivided into a hexagonal tiling, small regular hexagons of identical size.

For more information on Hexagnol grid, I recommend this fabulous Red Blob Games article.

Sprite

Sprite and Spritesheets have been used in games for a long time.

This include sprite animation and sprite collision detection.

Animations

Explosions

Explosions are an integral part of games. Not that all games need explosions, but they play an important role in the game dynamics.

Artificial intelligence

Pathfinding algorithms: A*

Audio

This is just a simple implementation of the HTML Audio to add sounds in a game.

Licence

ol-games is licenced under the French Opensource BSD compatible CeCILL-B FREE SOFTWARE LICENSE.
(c) 2017-2019 - Jean-Marc Viglino

Some resources (mapping services and API) used in this sofware may have a specific license.
You must check before use.

Full text license in English
Full text license in French

For convenience ol-games is also published under the BSD-3-Clause Licence.

ol-games's People

Contributors

viglino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ol-games's Issues

Example map.gameloop dont work?

https://viglino.github.io/ol-games/examples/map.gameloop.html

Mixed Content: The page at 'https://viglino.github.io/ol-games/examples/map.gameloop.html' was loaded over HTTPS, but requested an insecure stylesheet 'http://viglino.github.io/ol-ext/dist/ol-ext.css'. This request has been blocked; the content must be served over HTTPS.

Uncaught TypeError: ol.inherits is not a function
at ol-games.js:41
map.gameloop.html:100 Uncaught TypeError: ol.Game is not a constructor
at map.gameloop.html:100

:(

How to update image source of ol.Sprite ?

Hello, first of all, thanks for this lib!

I'm trying to change image within time or speed which comes through websocket. I couldn't find an official method to change it.

var animationObject = new ol.Sprite({
    position: [lon,lat],
    src: imgSrc1,
    size:64, // i'd like to be happy if there is an option "width and height" instead
    scale:1.5,
    opacity: 1,
    zIndex: 11,
     status: {
       idle: {
            line:0, length:1
        }
   }
});

then i want to change only "src".

animationObject.getStyle()[0].setImage(new ol.style.Sprite({
    src: (speed > 120) ? imgSrc2 : imgSrc1 ,
    size:64, // i'd like to be happy if there is an option "width and height" instead
    scale:1.5,
    opacity: 1,
    zIndex: 11,
}));
animationObject.setDestination(coord,speed);

after this set, nothing happens unless move/zoom on map.
Also i have an interval to check if device is in passive mode and not sending gps data So i change image to passive one.
Is there any better way to update image for this purpose?

ol: v5.2.0
ol-ext & ol-games: latest

unable to import FrameRate

Hi,
Thanks for your nice libraries, ol-ext & ol-games
I want to use itin a VueJS application, I installed the package from npm but I can't import the FrameRate to use with Sprite

HexMap error

ol_source_ImageCanvas.call (this, { canvasFunction: this.drawHex });

On above line (line 29 of HexMap.js) i am getting
Uncaught TypeError: Class constructor ImageCanvasSource cannot be invoked without new

When constructing the hex map per below

const hexgrid = new HexGrid ({ size:4000 });
const hexmap = new HexMap({ hexGrid: hexgrid });

I saw in ol-ext that you had to make some changes for ol 7 so maybe similar problems here ?

Control animation with seeker bar

Hi,
I'm using sprite path animation
Is it possible to show the animation like a movie? I mean to have a progress bar/seeker bar like media players, so we can show animation progress with progress bar/seeker bar and vice versa?

OL 6

Hi,

We have identified a problem to update OL6 with ol-ext and ol-games.
When installing packages, we get the following error message:

WARNING in ./node_modules/ol-games/source/HexMap.js 31:0-11
export 'inherits' (imported as 'ol_inherits') was not found in 'ol'

Do you know how we can solve this problem ?

Thanks,
Adrien

Computer cup is too high

不断的map.render() 导致电脑cup过高
Continuous map.render () causes computer cup to be too high

HexMap rotation

I am trying to rotate the entire hexagonal grid (canvas of HexMap)...

Unfortunately I haven't found a documented method of doing this through ol-ext and ol-games.
Do you have any idea if this might be possible with a herited method somewhere or with an other solution ?

How to get position/index of LineString while animating a sprite on it?

Hey @Viglino
I was animating a sprite (ex. plane) on a LineString. I have coords,date,speed..etc (comes from GPS device to the DB) and i draw a LineString from coords on map. While animating a sprite on it, i need to show other data on info window or popup which is appearing with select interaction. But i do not know the exact place a sprite on LineString.
This would be very nice idea if someone want to make timeline or info window like me while animating..

Is there any internal solution for this in the libs (ol-ext,ol-games?) .

  • If there's no solution for this, I'll try get closest point or something to get LineString position and calculate it manually.

Hope you have a better solution for ms.

NOTE:
I follow this instructions while animating a sprite:
https://viglino.github.io/ol-games/examples/map.sprite.path.html

While plane is flying, it would be better to show info about real time/speed/battery etc.

DB stores data like this:
[lon,lat,speed,time,total_km, battery_level...etc]

ol.Sprite.move() make misstakes when the direction is due east/ west/south

https://viglino.github.io/ol-games/examples/map.sprite.path.html

replace the path with
// 向上
var path2 = new ol.geom.LineString([
[265500, 6270000],[265500, 6280000],[265500, 6285000],[265500, 6290000],[265500, 6295000],[265500, 6300000],

]);
// 向下
var path = new ol.geom.LineString([
[265500, 6300000],[265500, 6295000],[265500, 6290000],[265500, 6285000],[265500, 6280000],[265500, 6270000],

]);
as you can see theirs difference

Sprites freezes when scrolling or moving the map

When a sprite is moving to a destination or along a path, if you scroll the map or move the map (I mean, drag the map around), the sprite freezes and won't move. When the map zooming/moving stops, the sprite jumps to the point where it should be. This can be see at https://viglino.github.io/ol3-games/examples/map.sprite.destination.html.

When you do the same thing using the feature animation with ol-ext (http://viglino.github.io/ol-ext/examples/animation/map.featureanimation.path.html), that does not happens. Any chances the issue with ol3-games is a easy fix?

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.