This question already has an answer here:
Shadows and directional light in phaser 3?
(1 answer)
Closed 10 days ago.
How can I implement Shadows With The phaser.js Webgl lighting system
this.lights.enable();
this.lights.setAmbientColor(0x808080);
Heres what I'm Looking for:
How Do I implement the shadows coming off those trees in phaser
As mentioned in this question/answer, as far as I know you cannot create shadows/shadow effects out of the box with in phaser. Except you want to programm it with raycasting or so(link to an article), but that would be alot of work judt for background feature, that mihht not be seen.
A easy solution could be use several background images, wirh different shadows an switch them out when needed (a possible example is in the aforementioned answer).
Related
What I need is simple actually, it is 3 arrows for each axis to be shown on the object, so that when I drag any of them the object will change its position accordingly. This is widely used in 3d modeling application such as 3dsMax or Maya. I know you can create it from scratch, but doesn't ThreeJS have something ready or isn't there any ready solution?
I looked it up for a while and it seems this topic is not popular among ThreeJS community. Has anybody come across such thing?
This question already has an answer here:
can you animate an image on a canvas
(1 answer)
Closed 6 years ago.
Good afternoon. As the title states, I am trying to animate a 2d spritesheet on a canvas element for a simple 2d game that I am making. I have gone through nearly a dozen articles and have not found what I am looking for, which is instructions on how to go about doing this without help from any sort of library. You might say to me, well sir, you are crazy if you aren't going to take advantage of this freely available technology that could make your life easier. My response to that is that I am doing this for the sake of learning, because I want to become a better javascript developer, and grow to write bigger and better games. That being said, I guess my question is: how do I animate a spritesheet? (I want the player to be able to input directions with the arrow keys) Make no mistake: I am not asking for anyone to write code for me, rather I am asking where I can find the resources to teach myself how to do this on my own. Thanks everyone, much appreciated.
The answer is: canvas + RequestAnimationFrame. Here a great tutorial: http://www.williammalone.com/articles/create-html5-canvas-javascript-sprite-animation/
I was looking for an html5 + javascript 2d game project to join months ago. If you're interested I would like to collaborate with you on this project. Just let me know and enjoy the tutorial
You can create a simple animation loop creating a canvas in your html document:
<canvas id="cvs"></canvas>
This will be your "game board"
Then you can create a javascript file in where defining the game engine.
You can load an external image inside an image element like this:
var myImage = new Image();
myImage.src = "my-sprite-animation.png";
And defining a sprite:
var mySprite = sprite({
context: canvas.getContext("2d"),
width: 100,
height: 100,
image: coinImage
});
Then using the requestAnimationFrame method for creating an animation loop:
function gameLoop () {
window.requestAnimationFrame(gameLoop);
mySprite.update();
mySprite.render();
}
I'd like to create a hollow box with some holes in Three.js.
Currently I managed to create a hollow box by creating a regular geometry and pushing triangles by hand (I created the inner box and than the outer box and merged the two together).
What I would like to know is if there's a simper solution that would also allow me to create holes in the cube.
Now, I've done some research on this question and found out about CSG.js. While this library looks like it would be a perfect fit for my needs, I'm not so comfortable with incorporating it into my codebase as it wasn't updated in more than 4 years (last commit was done on the 20th of August, 2012.
So my question is - is there a (practical) way to achieve what I want without using CSG.js?
Also, if you have any way to address my concerns about CSG.js I would appreciate it very much.
P.S.: I would like to be able to control the shape of the hole as well - but for simplicity sake let's say I'm talking about diamond-shaped (Rhombus) holes.
This question already has an answer here:
How do I create image connecting two vertices in mxGraph?
(1 answer)
Closed 9 years ago.
I want to create a specific connection between two nodes. The connection would have an image. Is this possible?
I work with mxGraph, javascript.
http://upload.wikimedia.org/wikipedia/commons/0/08/Simple_stock_and_flow_diagram.gif
Sorry, for my english. Thanks.
You'll need to (and I'm looking at the v2 API here) create your own edge shape, most likely based on mxConnector (in the shape folder). paintEdgeShape defines the rendering of the edge, you use the canvas API to define that drawing (see API specifications for mxAbstractCanvas2D).
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I know object oriented PHP and Java, and I can code Javascript fairly well at the moment.
However for the life of me I'm not sure how Google's made a game in JavaScript.
It seems to be compressed (the code) so I can't really see what's going on.
I thought javascript it was only single threaded too, making game development even harder.
I've seen the GWT, but I thought that was more for designing interfaces, I didn't really see any game development in there. If someone could direct me to some sort of toolkit, or open my eyes to how people are coding games in Javascript, I sure would appreciate it!
Google (if you are thinking of the pacman game), used HTML5's new feature which supports a kind of 'threading' called WebWorkers. You can also use timeouts and such to pretend to be using threads, though in reality they aren't.
Writing a game in Javascript is similar to how you would do it in C. Or rather, messy C with most things in one file. You have to just define all your components in the one javascript file (or multiple if you are using WebWorkers) and press your go button. Graphics are largely done with HTML5's canvas 2d element or if you are really on edge, the canvas 3d WebGL system which isn't really supported properly in all modern browsers yet.
In fact, you can make a game simply by setting up one big Canvas 100% width and height, and then program your entire system in that javascript file, ignoring the fact that you are on the web (if you please). Most usual drawing, threading, database, networking, etc... standard game 'features' are already built in to the latest HTML 5 spec.
This SO question on a javascript games framework should help and google turned up gameQuery and GameJS...that should at least provide some insight into what's being done.
This site also has a gallery of javascript based games...
It's really hard to make complicated game in Javascript now, mostly because of browsers incompatibility. But google guys made port of quake 2 to Javascript with GWT.
To make your own game you can use HTML5 canvas or better vector graphic (VML for IEs and SVG for others) maybe with raphael.js library as abstraction layer. Also you can use some physics engine like Box2DJS
3D Javascript game is not an option now, because WebGL is under development.