GithubHelp home page GithubHelp logo

tileset about gamequery HOT 4 CLOSED

onaluf avatar onaluf commented on May 25, 2024
tileset

from gamequery.

Comments (4)

FostUK avatar FostUK commented on May 25, 2024

Tiledef is a 2d array so you can use:

var tiledef = [ [1,2,3], [4,5,6], [7,8,9] ]; //use 0 to display no tile.

The integer is an index into an animation.
Most people will want to set up large set of non-animating tiles.
This is the bit that took me a while to get when using a multi animation to select tiles from a sprite sheet you need to set it up in the following way (single frame, multiple animations, once sprite sheet, no looping)

Using a horizontal strip of 50 tiles each 32X32 pixels

var multiAnimation = new $.gameQuery.Animation
                         ({
                            imageURL: "/graphic/temp/Ground1.png",
                            type: $.gameQuery.ANIMATION_VERTICAL | $.gameQuery.ANIMATION_MULTI | $.gameQuery.ANIMATION_ONCE,
                            numberOfFrame: 1,
                            delta: 32,
                            distance: 32, 
                            rate: 30
                          });

var tiledef = [[1,2,3,4,5,6,7,8,9,10],[11,12,13,14,15,16,17,18,19,20]];

$.playground().addTilemap
(
    "myTilemap",
    tiledef,
    multiAnimation,
    {width: 32, height: 32, sizex: 10, sizey: 10, posx: 0}
);

$.playground().startGame();

from gamequery.

hososugi avatar hososugi commented on May 25, 2024

After I posted this I just used PHP to just make a nested loop to accomplish basically the same thing, but it was making my game slow, so I tried just making one large bmp for the background and it's much faster. I haven't compared actual frame rates though. Have you tried comparing them?

from gamequery.

FostUK avatar FostUK commented on May 25, 2024

Haven't done any benchmarking but it would make perfect sense that moving around lots of small divs would slow down the system a lot. I guess these days a really large jpeg isn't going to do much harm. Perhaps once the optimisation for off playground tiles is in it will be worth benchmarking though. There's clearly some design advantages for some types of games by using tiles.

from gamequery.

onaluf avatar onaluf commented on May 25, 2024

One advantage of tilemap is that you can use collision detection to find out what kind of tile a sprite is touching. That's very convenient for a platformer for example. When the tiles are animated on the visible one get updated this make the use of quite large animated tilemap quite fast, for very large map there should be a solution comming to gQ 0.7.

from gamequery.

Related Issues (17)

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.