Closed TKanX closed 1 week ago
https://github.com/tridecco/game-client-web/commit/a837665f1157557885781de972dfaed4ede2a848
GameRenderer
class to handle rendering of the game map.
GameMap
object and a canvas element.ctx
) is obtained from the provided canvas.canvas
with the id="game-canvas"
for the canvas element in the game view.Note: Further implementation is needed to render the actual game elements on the canvas.
https://github.com/tridecco/game-client-web/commit/178547fd7d381d58d626f189e3ff169db7a20c17
https://github.com/tridecco/game-client-web/commit/b6a5ca88a8815e8ab6706b17a69f1928dfece460
backgroundImage
parameter.loaded
._initRenderer
method to set up the renderer with the new background image._initRenderer
.https://github.com/tridecco/game-client-web/commit/aea51d0136ade5a95c2dfff36de80609644bc255
https://github.com/tridecco/game-client-web/commit/204d04c6bc81aa4245aa5bf95b9d351c050772b7
window.innerWidth
and window.innerHeight
.https://github.com/tridecco/game-client-web/commit/f4622243fa29df54342a6d8ee8a61cc98b99cef8
https://github.com/tridecco/game-client-web/commit/8749f6acea21cf0145280f7945f997ba8c49f231
resizeCanvas
method to update canvas dimensions based on the window size.resizeCanvas
when the window is resized.drawBackgroundImage
to use the current canvas size and background image.https://github.com/tridecco/game-client-web/commit/0a6613f9d863c48cb5229c56f2e8d20332cd66f4
map
parameter type from Array
to Object
for better flexibility._loadImage
method to handle image loading with Promises.setMap
method to load and cache tile images for the game map.drawMap
method to handle tile scaling, rotation, and rendering on the offscreen canvas.https://github.com/tridecco/game-client-web/commit/6782b6d5975d9cc6457057eabb811cba70859773
drawPiece(position)
method to render a specific piece at the given position.clearPieces()
method to clear the canvas and redraw the background image and game map.https://github.com/tridecco/game-client-web/commit/b5978c83b651264eb945884d1dc5f513ca2a3a09
Corrected the misspelled variables 'acaleX' and 'acaleY' to 'scaleX' and 'scaleY' respectively. This change ensures proper scaling calculations in the game renderer when converting board coordinates to canvas pixel coordinates.
https://github.com/tridecco/game-client-web/commit/692333ce8103b0d6584ec2d8af17a2e90bd16632
_handleClick(event)
method to detect and handle clicks on specific pieces.addClickListener(handler)
method to allow registration of click event handlers.https://github.com/tridecco/game-client-web/commit/184c6d0cc40dd1aec0b54a30edceb642a6f8d42d
_loadTileImages()
method to load tile images asynchronously.https://github.com/tridecco/game-client-web/commit/8ee56370b645e8aa73da22b43cee52aaeaefbb0e
pieces
array to store drawn pieces for restoration._restorePieces
method to redraw pieces after canvas resize.resizeCanvas
method to restore pieces after resizing.drawPiece
to store pieces in the pieces
array.clearPieces
to reset the pieces
array after clearing the canvas.https://github.com/tridecco/game-client-web/commit/baf8760185b8e8b3008e6e3504ddee4d69950e1e
requestAnimationFrame
.resizeCanvas
with debounced function to improve performance during frequent resize events.https://github.com/tridecco/game-client-web/commit/e51b9b26f1bf786c9baabf30654a044f34100d3e
https://github.com/tridecco/game-client-web/commit/c4a04fcd5ddd3b352ee4afaaa192ad1a5da55b7e
The drawPiece
method in the GameRenderer
class has been updated to handle flipped tile images. This ensures that the correct image is used based on the flipped
property of the tile.
https://github.com/tridecco/game-client-web/commit/75cc9077470540bab8422073a644deea470d6869
public/maps/default.json
for game board rendering.@tedhyu
that looks amazing! Is there any plans that once a gem forms to change the image to the hexagon image?
that looks amazing! Is there any plans that once a gem forms to change the image to the hexagon image?
Hi Dr. Yu,
Thank you for the feedback! Yes, the image you saw was just from a randomly generated rendering test, which served as a unit test. Integrating this with the network layer is still in progress, and I'm planning to refactor the server-side network layer as well. The idea of changing the image to a hexagon once a gem forms is also in the plan. Appreciate your suggestion!
@tedhyu
https://github.com/tridecco/game-client-web/commit/c498e41feb82cdbd40ff095b36b3747a7593cd9e
Wow. Thanks for the demo. It looks great.
Also, keep in mind that if you are interested, you can add advertising to the page and keep the earnings. You should be rewarded for your hard work. We can think about it later when the game gets up and running smoothly.
https://github.com/tridecco/game-client-web/commit/2a0e0f0f928ca470066973064d46a57c6ac8a9eb
_handleClick
method where the testing canvas was not correctly cleared, leading to incorrect click event detection.clearRect
call to ensure the testing canvas is properly cleared after processing each tile.Also, keep in mind that if you are interested, you can add advertising to the page and keep the earnings. You should be rewarded for your hard work. We can think about it later when the game gets up and running smoothly.
Hi Dr. Yu, Thank you for the suggestion! I'm really doing this out of passion, and seeing the project succeed is the biggest reward for me.
@tedhyu
https://github.com/tridecco/game-client-web/commit/84d0ee9d73b7e2b09a8338eb45bf780f5456a41f
Added the willReadFrequently
option to the canvas context to enhance performance for frequent getImageData
operations. This change helps reduce memory overhead and improve the speed of pixel data access, particularly useful in scenarios involving intensive image processing or frequent canvas updates.
https://github.com/tridecco/game-client-web/commit/b01f85ef1c9b94d4186652b074ab471636085a95
This commit refactors the GameRenderer
class to optimize canvas rendering and improve resize handling. The changes include:
offscreenCanvas
and offscreenCtx
variables.resizeCanvas
method to calculate the scaling factors scaleX
and scaleY
only once.clearRect
calls in the resizeCanvas
and clearPieces
methods.drawMap
logic into the resizeCanvas
method to eliminate redundant drawing.These optimizations enhance the performance and user experience of the game rendering, resulting in smoother gameplay and faster display updates.
https://github.com/tridecco/game-client-web/commit/e522fe0874584bd96e27af11d16ff2e895dd6717
showAvailablePositions
method to visually indicate the available positions where tiles can be placed.hideAvailablePositions
method to clear the highlighted areas and restore the board's state.https://github.com/tridecco/game-client-web/commit/32f0e1577470060b4dd20926af1f80f4e9daa037
The code changes in public/js/game.js
modify the GameRenderer
class to use the flipped tile image for black tiles. This ensures that the correct image is displayed based on the flipped
property of the tile. This improvement enhances the visual representation of the game board and provides a more accurate rendering of the tiles.
https://github.com/tridecco/game-client-web/commit/95c75bcf1e81f5761a2c67eff2adbc59e634dcb5
Added functionality to display available positions when the player's turn begins. The renderer.showAvailablePositions
method is called when the game:turn
event is triggered for the current player with a normal turn type, and renderer.hideAvailablePositions
is invoked when the turn ends. This enhances the UI by visually indicating valid move locations.
https://github.com/tridecco/game-client-web/commit/a616fc6ac25adc74591c4c231781ce5d9f48dc90
Added a network listener for the "game:toss" event to handle the tossing of a game piece. The listener retrieves the player ID, piece index, and position from the event data and uses them to draw the corresponding piece on the game board. This enhances the visual representation of the game and improves the overall gameplay experience.
https://github.com/tridecco/game-client-web/commit/2008f90f7469edc2acfe81590cddacf23cc99346
showTossButton
method to GameUI
to display the toss button and handle the click event.hideTossButton
method in GameUI
to hide the toss button after the toss action.Game
class to listen for the "game:tossStart" event and show the toss button for the current player.Game
class, the toss button triggers the tossPiece
method via the network, which emits a "game-client:toss" event to the server.tossPiece
method to GameNetwork
to handle the client-side toss action by emitting the appropriate event.https://github.com/tridecco/game-client-web/commit/1d352cd04b50a9ea417c1aeeb8f13f73509f7f2b
_restoreAvailablePositions
to the GameRenderer
class to restore the available positions on the canvas after resizing.https://github.com/tridecco/game-client-web/commit/df95ac48356601427fbda67d6bb5271a027cb472
GameNetwork
to handle the "game:placePiece" event.drawPiece
method.https://github.com/tridecco/game-client-web/commit/f070d65246fd43b77ca323f434308ccc65a56355
game:round
event listener to clear pieces from the board if the round is not the first.https://github.com/tridecco/game-client-web/commit/dfec912ffb527fe6ddc9543cf0422d2339b4c17c
clearPieces
to ensure the canvas and pieces cache are properly cleared after each round.clearPieces
method into a private _clearPieces
function for better encapsulation.https://github.com/tridecco/game-client-web/commit/65dd6c5867b4830b4db8beb0b22f81495e71dc32
cleanUp
method to the GameRenderer
class to properly clean up resources after the game ends.
Description:
Develop the game view and rendering layer using the HTML5 Canvas API to provide a visually appealing and interactive user interface for the game. This layer will handle rendering the game board, pieces, and other visual elements, as well as managing user interactions within the game.