Questions tagged [html-canvas]
A new feature of HTML5, allowing Javascript apps to have a drawing surface in the browser.
395 questions
0
votes
0
answers
61
views
Android canvas clipping rectangle showing on canvas draw call with paint object that has blurmaskfilter and shadowlayer
I created a game using xml and views on Android. Yes, I know it was not the best choice of development for a 2d game. But, my game is turn based, so mostly static. You can test the game out here: ...
1
vote
1
answer
90
views
2D Square Collision Correction issue detecting which direction
I've just started getting into 2D game development and have been experimenting with some 2D collision and correction logic in canvas. I'm trying to debug this block of code and understand why it is ...
1
vote
0
answers
60
views
Develop a dialogue system for a game in html 5 canvas
similar to rpgs with a popup window and text options. like stardew valley. Are there any common approaches to implement this?
0
votes
0
answers
109
views
`textSubImage2D` inconsistent performance
I have a problem when creating a texture with WebGL. The thing that I do not understand is that the first call with texSubImage2D with a canvas leads to the ...
0
votes
1
answer
247
views
Camera movement with player
I'm developing a game using the html5 canvas, but I've never used it before and I'm having difficulty creating a camera. The intention is that it is the same as agar.io, where the player is centered ...
1
vote
1
answer
224
views
Would it be possible to make a Game Genie like program in Javascript?
Game Genie was a tool for the NES that allowed users to input codes that were able to drastically able to change the mechanics of a game by getting CPU reads and replacing the game's response with its ...
0
votes
0
answers
84
views
Handle roads following in a javascript game
In a browser game made in HTML5/Javascript, I would like to handle the move of units in real-time. But units would have to follow some predefined roads...
Canvas seems better than svg to handle ...
0
votes
2
answers
379
views
What is the best way to store level data in HTML5
I am currently making a game in HTML5 using canvas, and it is currently just 1 js script and HTML file with references to png files for assets. Right now, I have the level data baked into the script, ...
0
votes
0
answers
183
views
Unity WebGL Game's Canvas UI scale changes with windows scale
So this is the setting that is affecting my game. My game is a webgl build from unity running in chrome, hosted on itch.io.
At 100% windows scaling setting, the UI elements have expected size,...
0
votes
1
answer
76
views
Adding requestAnimationFrame in isometric Tile grid Code is not working
Hi There this is my first Post on gamedev, and i hope everyone understand what i want :)
First of all my Code is an very Personal Version from one Github Isometric Map.
I Tryd now 2 Days to Add the ...
0
votes
1
answer
94
views
Why is this code keeping the listener which should be removed instead?
I am having some issues figuring out why this code still lets btn_1 call the function setstate3().
There is a function ...
0
votes
1
answer
40
views
why does my button lose the changed cursor and mouseover behaviour as soon as I attach a class to my file?
Using adobe animate cc - exporting to HTML5 and coding in JS (or at least trying to)
If I just hit cntrl+enter in adobe animate the button works as expected.
If I run the app from a web server using ...
1
vote
1
answer
1k
views
How to fit game to screen size?
I create a WebGL game. After building project I discovered that the game doesn't fit the screen size
How you can see the canvas is perfectly scaled but the game didn't
I don't know what I changed but ...
0
votes
1
answer
883
views
How to pan and zoom an isometric map on a canvas
I'm new to html canvas.
So far I am following this code as base for simple isometric tiles.
I made an empty isometric grid map that only shows the grid.
I want to offset the position of my isometric ...
0
votes
1
answer
202
views
How to spread circles evenly around a point?
In my game there's a part where a bunch of circles need to evenly spread around a point. Like in this demo below:
...
0
votes
1
answer
292
views
Invisible sprites with requestAnimationFrame
I'm trying to animate a sprite sheet. I have a single image, and multiple objects of the same type but drawn at different locations on the canvas.
What I'm trying to do is have each object move with ...
0
votes
1
answer
89
views
How do I go about creating images, which are units with traits?
Lets say there are 5 units, displayed as images on an html5-canvas.
Each image (unit) has a different size. For the game I need to know the size of that unit, and also it's middle point.
How and where ...
0
votes
1
answer
432
views
Struggling with breadth first search for hex grid
I cant seem to get breadth first search right. Ive gone through redblobs implementation guides of hex grids and have that all figured out but pathfinding is proving to be difficult.
So I have a search ...
0
votes
1
answer
151
views
How to add a texture that follows the movement?
I would like to move my landscape to simulate a world moving on the x-axis. I use createPattern() to add an image inside my path, but the pattern draws the image at ...
0
votes
1
answer
503
views
Alternative to redrawing the background canvas for camera movements?
I have multiple canvases placed on top of each other for different layers (background, game objects, foreground). I was expecting this to allow me to have the background and foreground update at a ...
3
votes
0
answers
1k
views
What is causing my touchstart event to end while I'm still touching the screen, and how can I fix that?
What I'm trying to do:
I'm trying to add touch controls to games created with the html canvas and JavaScript so that they can be used on mobile / tablet devices.
The controls should simply move a ...
0
votes
1
answer
554
views
0
votes
1
answer
2k
views
find one meter to scale in earth heightmap
I have a heightmap that scales from 0 to 255. the map is only for elevation (discluding water and ice) what would be the appropriate way to calculate the scale of one meter? heightmap below
0
votes
1
answer
2k
views
How to rotate an image around its center point in a JavaScript canvas?
I have this function to get the rotation angle from my sprite and a target:
...
0
votes
1
answer
125
views
using javascript canvas.context.scale resets custom font
I am making a HTML5 game using javascript with canvas.
I am implementing a custom font adding @font-face style tag to header in the .html file, then if I set ...
1
vote
0
answers
37
views
How can I calculate initial X and Y velocity given the starting coordinates, target coordinates, friction and duration? (No gravity)
I am really new to mixing physics and game development, and I would like to find the initial velocity required to launch the gray dot from point A to point B, given a time. I’ve tried many tutorials ...
1
vote
1
answer
1k
views
Help me Make Sense of Unity 2D Resolution Management
I am trying to set up an environment for a retro style pixel art game in Unity 2D. I aim for a vertical resolution of 240 pixels, and then, I would like the horizontal resolution to be dependent on ...
1
vote
1
answer
127
views
How to add zombie arms to enemies in HTML canvas
I'm making a game with HTML canvas (not WEBGL). I have zombies that go to the center of the screen, but for now they are just circles. I want to give them two arms, like the arms players have in ...
2
votes
2
answers
3k
views
Performance of many canvas drawImage calls is very slow
I'm developing a top-down 2D tile-based canvas game. I have a single sprite sheet of all my tiles, and then a JSON tile map array of where they're placed.
Previously I would render all the layers of ...
2
votes
2
answers
2k
views
How to make 2D lighting in JavaScript
I am making a recreation of the 2D voxel game Terraria in JavaScript. Like most sandbox games, Terraria has lighting, but because I am using JavaScript, performance is going to be an issue.
I have ...
0
votes
1
answer
55
views
Line strokes also adding borders to other shapes?
When you run the project, you can see that the first circles have a black border around them. When I remove the Game.drawLines(), the circles don't have the border ...
0
votes
1
answer
160
views
How to Generate Level Map Based on Golden Ratio
I am trying to generate a map based on the Golden Ratio:
a+b is to a as a is to b.
I was looking at a JavaScript math library that had a built-in phi, but I wasn'...
3
votes
3
answers
3k
views
What is the "Unity" way to approach tech design for a 2D game like this?
So I come from C++ land where I've always done every little thing myself. Now I'm getting into Unity and C# and I'm ironically overwhelmed with the domain. I'm starting off with this simple little 2D ...
7
votes
1
answer
5k
views
Completely Pixelated Font in JavaScript Canvas?
I'm making a game with a canvas scaled up such that each pixel is pretty big. I want to display some pixelated text without anti-aliasing but I have idea how I would accomplish this.
Is there I way ...
1
vote
1
answer
1k
views
My HTML Canvas went blank
I tried to draw Mario Sprites in my HTML Canvas, but it always went blank.
Anybody knows why?
...
0
votes
1
answer
414
views
I can't clear the paint image in my Canvas
I'm trying to make the Mario move, but somehow it leaves traces behind, can anybody help???
...
2
votes
2
answers
5k
views
My HTML canvas keep flickering
I'm trying to create a game in HTML canvas, but somehow it keeps flickering, I've taken a look at the tutorial and I perceived that my code is more or less similar. Can anybody help me fix this?
<...
0
votes
2
answers
1k
views
World space UI stretched too much instead of billboard in unity
I am scaling my world space UI element as my camera go far away from UI using this code snippet:
...
0
votes
1
answer
451
views
how to join the body of snake in 2D snake game
i'm making a snake game in javaScript from scratch. The problem is that the snake looks disjoint(see image). How can I connect the body(rectangles) of the snake?
here is the code of drawing snake:
<...
0
votes
0
answers
1k
views
html5 canvas isometric tile map
i need a help i have an Isometric Staggered tile map in Tiled (mapeditor.org).
100x100 tiles, 94x54px, 9447x2727px. total.
How can i make this in html5 canvas ?
var context = document....
0
votes
0
answers
38
views
Platformer collision detection problem - player snapping onto sides [duplicate]
I am having problems with collision detection. I am trying to make a simple platformer but when the player is falling or moving too fast it sometimes detects the wrong collision side. I am getting the ...
0
votes
1
answer
275
views
How to get the address of a nearby square on a chess board?
I'm making a chess game from scratch and I got stuck.
So far I have all my figures placed, I have the positions set, I've already done the collision detection and everything.
When I click the figure ...
-1
votes
1
answer
2k
views
Calling setInterval from requestAnimationFrame causes enemies to shoot continuously
I am making a 2D canvas game in JavaScript. I am trying to make the enemies shoot a bullet every 3 seconds.
...
0
votes
1
answer
702
views
Making an enemy shoot every few seconds
so I am making a 2d canvas game in Javascript and I want the enemy mobs to shoot a bullet every let's say 3 seconds. I'm almost done with the code , i made everything i just don't know how to make the ...
0
votes
1
answer
917
views
How do I change the level of my game by changing the file loaded?
I am making this 2d canvas game in JavaScript and I want to switch to file level2/level2.html when the boss of level 1 (...
-1
votes
1
answer
526
views
WebGL-HTML5 canvas in two blogger blog posts show individually but not together?
In my blogger blog: https://cglabprojects.blogspot.com
I have a newer blog post with
<canvas width = "570" height = "570" id = "my_Canvas1"></canvas>
...
1
vote
0
answers
74
views
Problem with collisions detection on canvas platformer
Having a lot of trouble with my collision detection in my platformer. If you go straight to the right the block will float. Also the corners let the block sink right through and the walls are sticky. ...
0
votes
2
answers
113
views
How can I delete an object when it's not stored in an array?
I have a boss appearing in my game, but since it's only one character I didn't put it in an array. Now I'm trying to make disappear if its health is less or equal to 0 but I don't know how to do that. ...
-1
votes
2
answers
645
views
I need help with calculating the angle my character is aiming at
So im doing this program where i want my hero to shoot to the direction its facing , but for this job to get done i need to calculate the angle my hero is facing with Math.atan2() , atleasts thats ...
1
vote
1
answer
473
views
Collision detection between two arrays with nested loops: why do I get a crash?
I'm creating a game where waves of enemies are coming to me and I have to kill them.
So far, I'm doing great: it took me hours to come up with this nested loop to check for collision detection and ...