Skip to content

Commit

Permalink
Updates Playground
Browse files Browse the repository at this point in the history
  • Loading branch information
Marak committed Feb 29, 2024
1 parent b54d36a commit 566238c
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 107 deletions.
59 changes: 26 additions & 33 deletions mantra-client/public/worlds.mantra.js
Original file line number Diff line number Diff line change
Expand Up @@ -6130,31 +6130,6 @@ var Playground = exports["default"] = /*#__PURE__*/function () {
this.id = Playground.id;
}
_createClass(Playground, [{
key: "init",
value: function init(game) {
this.game = game;
game.config.defaultMouseMovement = false;

// Movements with right click, switch default left-click-to-move behavior
game.config.mouseMovementButton = 'RIGHT';
// Actions with left click
game.config.mouseActionButton = 'LEFT';
// enables the default top-down mouse movements
game.config.defaultMouseMovement = true;
game.reset();
game.data.camera.mode = 'none';

// Remark: Not ideal for mapping Mouse buttons,
// as they should be conditionals in Sutra tree like Keyboard events are
var mouse = game.systems.mouse;
mouse.setButtonMapping('LEFT', 1);
mouse.setButtonMapping('MIDDLE', 0);
// enables mouse wheel zoom
game.data.camera.mouseWheelZoomEnabled = true;
this.createWorld();
this.setDefaultZoom();
}
}, {
key: "preload",
value: function () {
var _preload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(game) {
Expand Down Expand Up @@ -6185,6 +6160,31 @@ var Playground = exports["default"] = /*#__PURE__*/function () {
}
return preload;
}()
}, {
key: "init",
value: function init(game) {
this.game = game;
game.config.defaultMouseMovement = false;

// Movements with right click, switch default left-click-to-move behavior
game.config.mouseMovementButton = 'RIGHT';
// Actions with left click
game.config.mouseActionButton = 'LEFT';
// enables the default top-down mouse movements
game.config.defaultMouseMovement = true;
game.reset();
game.data.camera.mode = 'none';

// Remark: Not ideal for mapping Mouse buttons,
// as they should be conditionals in Sutra tree like Keyboard events are
var mouse = game.systems.mouse;
mouse.setButtonMapping('LEFT', 1);
mouse.setButtonMapping('MIDDLE', 0);
// enables mouse wheel zoom
game.data.camera.mouseWheelZoomEnabled = true;
this.createWorld();
this.setDefaultZoom();
}
}, {
key: "createWorld",
value: function createWorld() {
Expand Down Expand Up @@ -6247,10 +6247,7 @@ var Playground = exports["default"] = /*#__PURE__*/function () {
}).style({
cursor: 'pointer'
}).position(-500, 150).size(128).createEntity();

// TODO: remove createContainer, upgrade to Container() plugin instead

var container2 = game.make().Container({
game.make().Container({
layout: 'grid',
grid: {
columns: 7,
Expand Down Expand Up @@ -6603,10 +6600,6 @@ var Playground = exports["default"] = /*#__PURE__*/function () {
return Playground;
}(); //let entities = text2Entities(text);
_defineProperty(Playground, "id", 'world-playground');
// "world" type has special features in that it can be unloaded and reloaded.
// with special rules such as merge, replace, etc.
// this is currently used when switching between worlds in the GUI Editor
// the default behavior is to unload the world, then load the new world
_defineProperty(Playground, "type", 'world');
function text2Entities(text) {
var entities = [];
Expand Down
2 changes: 1 addition & 1 deletion mantra-client/public/worlds.mantra.min.js

Large diffs are not rendered by default.

74 changes: 35 additions & 39 deletions mantra-worlds/Playground/Playground.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,33 @@ let exampleRoot = 'https://yantra.gg/mantra/examples';

export default class Playground {
static id = 'world-playground';
// "world" type has special features in that it can be unloaded and reloaded.
// with special rules such as merge, replace, etc.
// this is currently used when switching between worlds in the GUI Editor
// the default behavior is to unload the world, then load the new world
static type = 'world'; // type is optional for Plugins
constructor() {
this.id = Playground.id;
}

async preload(game) {

game.use('Button')
game.use('Code')
game.use('Container')
game.use('Editor')
game.use('Hexapod')
game.use('Iframe')
game.use('Image')
game.use('Link')
game.use('Platform')
game.use('Player')
game.use('Select')
game.use('Teleporter')
game.use('Text')

}

init(game) {
this.game = game;
game.config.defaultMouseMovement = false;

game.config.defaultMouseMovement = false;

// Movements with right click, switch default left-click-to-move behavior
game.config.mouseMovementButton = 'RIGHT';
Expand All @@ -34,25 +48,9 @@ export default class Playground {
mouse.setButtonMapping('MIDDLE', 0);
// enables mouse wheel zoom
game.data.camera.mouseWheelZoomEnabled = true;

this.createWorld();
this.setDefaultZoom();
}

async preload(game) {

game.use('Button')
game.use('Code')
game.use('Container')
game.use('Editor')
game.use('Hexapod')
game.use('Iframe')
game.use('Image')
game.use('Link')
game.use('Platform')
game.use('Player')
game.use('Select')
game.use('Teleporter')
game.use('Text')

}

Expand All @@ -71,20 +69,20 @@ export default class Playground {
.createEntity();

let link = game.make()
.Link({
href: 'https://yantra.gg/mantra/home',
target: '_blank'
})
.style({
fontSize: '32px',
color: 'purple',
})
.text('/examples/games/home')
.width(600)
.height(20)
.x(-100)
.y(-440)
.createEntity();
.Link({
href: 'https://yantra.gg/mantra/home',
target: '_blank'
})
.style({
fontSize: '32px',
color: 'purple',
})
.text('/examples/games/home')
.width(600)
.height(20)
.x(-100)
.y(-440)
.createEntity();

let sideTextGroup = game.make().name('side-text-group').style({
border: 'none',
Expand Down Expand Up @@ -148,9 +146,7 @@ export default class Playground {
.size(128)
.createEntity();

// TODO: remove createContainer, upgrade to Container() plugin instead

let container2 = game.make()
game.make()
.Container({
layout: 'grid',
grid: {
Expand Down
59 changes: 26 additions & 33 deletions mantra-worlds/dist/worlds.mantra.js
Original file line number Diff line number Diff line change
Expand Up @@ -6130,31 +6130,6 @@ var Playground = exports["default"] = /*#__PURE__*/function () {
this.id = Playground.id;
}
_createClass(Playground, [{
key: "init",
value: function init(game) {
this.game = game;
game.config.defaultMouseMovement = false;

// Movements with right click, switch default left-click-to-move behavior
game.config.mouseMovementButton = 'RIGHT';
// Actions with left click
game.config.mouseActionButton = 'LEFT';
// enables the default top-down mouse movements
game.config.defaultMouseMovement = true;
game.reset();
game.data.camera.mode = 'none';

// Remark: Not ideal for mapping Mouse buttons,
// as they should be conditionals in Sutra tree like Keyboard events are
var mouse = game.systems.mouse;
mouse.setButtonMapping('LEFT', 1);
mouse.setButtonMapping('MIDDLE', 0);
// enables mouse wheel zoom
game.data.camera.mouseWheelZoomEnabled = true;
this.createWorld();
this.setDefaultZoom();
}
}, {
key: "preload",
value: function () {
var _preload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(game) {
Expand Down Expand Up @@ -6185,6 +6160,31 @@ var Playground = exports["default"] = /*#__PURE__*/function () {
}
return preload;
}()
}, {
key: "init",
value: function init(game) {
this.game = game;
game.config.defaultMouseMovement = false;

// Movements with right click, switch default left-click-to-move behavior
game.config.mouseMovementButton = 'RIGHT';
// Actions with left click
game.config.mouseActionButton = 'LEFT';
// enables the default top-down mouse movements
game.config.defaultMouseMovement = true;
game.reset();
game.data.camera.mode = 'none';

// Remark: Not ideal for mapping Mouse buttons,
// as they should be conditionals in Sutra tree like Keyboard events are
var mouse = game.systems.mouse;
mouse.setButtonMapping('LEFT', 1);
mouse.setButtonMapping('MIDDLE', 0);
// enables mouse wheel zoom
game.data.camera.mouseWheelZoomEnabled = true;
this.createWorld();
this.setDefaultZoom();
}
}, {
key: "createWorld",
value: function createWorld() {
Expand Down Expand Up @@ -6247,10 +6247,7 @@ var Playground = exports["default"] = /*#__PURE__*/function () {
}).style({
cursor: 'pointer'
}).position(-500, 150).size(128).createEntity();

// TODO: remove createContainer, upgrade to Container() plugin instead

var container2 = game.make().Container({
game.make().Container({
layout: 'grid',
grid: {
columns: 7,
Expand Down Expand Up @@ -6603,10 +6600,6 @@ var Playground = exports["default"] = /*#__PURE__*/function () {
return Playground;
}(); //let entities = text2Entities(text);
_defineProperty(Playground, "id", 'world-playground');
// "world" type has special features in that it can be unloaded and reloaded.
// with special rules such as merge, replace, etc.
// this is currently used when switching between worlds in the GUI Editor
// the default behavior is to unload the world, then load the new world
_defineProperty(Playground, "type", 'world');
function text2Entities(text) {
var entities = [];
Expand Down
2 changes: 1 addition & 1 deletion mantra-worlds/dist/worlds.mantra.min.js

Large diffs are not rendered by default.

0 comments on commit 566238c

Please sign in to comment.