RPG with world moving but not player

75 views
Skip to first unread message

Mark Juchems

unread,
Dec 26, 2019, 3:13:41 PM12/26/19
to Crafty
Not sure how to describe this, but Iwould like to use crafty.js for an RPG game.  If you are familiar with the game "shadow keep" on the early macs, the person stands in the middle and the world moves under him.

The example RPG on the crafty home page shows the man running around in a world.  The world is stationary and the man moves.  I want the opposite.

Will crafty do that?  Anyone know an api that will do it?

I have gotten this to run before with straight javascript and a <table> tag. I wanted something more elegant than that.

mark

Lex Light

unread,
Dec 26, 2019, 5:39:17 PM12/26/19
to Crafty
I'm not sure how to do this in crafty, but I think the usual way of achieving this is to lock the viewport to the character.

VOLThor6

unread,
Mar 2, 2020, 2:43:46 PM3/2/20
to Crafty
I think you can accomplish that with this. Taken from the cookbook thread:

Description:
This fiddle illustrates one way of loading a large (1280x1280) background image for a game world.
The player can be moved around using the up, down, left, and right arrow keys, in increments of 32 pixels.
The Crafty viewport follows the player, and the stage is 500x500 pixels. There is no collision detection, but you could extend this to use Crafty's collision detection.
The fiddle requests sprites from the OpenGameArt.org website, which is a great resource for sprites to use in your own game.

I've adopted this approach for a game that I am working on. I found that having a small viewport with a scrolling background works well on mobile devices, due to limited screen space.

Fiddle:
http://jsfiddle.net/FpNaF/

Reply all
Reply to author
Forward
0 new messages