tridecco / game-client-web

Tridecco Game Client is a frontend application designed to support Tridecco games. It provides user interface rendering, user interaction handling, dynamic content loading, and communication with the backend server.
https://play.tridecco.com
GNU Affero General Public License v3.0
1 stars 0 forks source link

Implement Game View and Rendering Layer #18

Closed TKanX closed 1 week ago

TKanX commented 1 month ago

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.

TKanX commented 3 weeks ago

Added GameRenderer class and integrate canvas element

https://github.com/tridecco/game-client-web/commit/a837665f1157557885781de972dfaed4ede2a848

Note: Further implementation is needed to render the actual game elements on the canvas.

TKanX commented 3 weeks ago

Optimized game canvas rendering for square aspect ratio and centering

https://github.com/tridecco/game-client-web/commit/178547fd7d381d58d626f189e3ff169db7a20c17

TKanX commented 3 weeks ago

Updated GameRenderer constructor and Game class

https://github.com/tridecco/game-client-web/commit/b6a5ca88a8815e8ab6706b17a69f1928dfece460

TKanX commented 3 weeks ago

Resized game canvas to match container dimensions

https://github.com/tridecco/game-client-web/commit/aea51d0136ade5a95c2dfff36de80609644bc255

TKanX commented 3 weeks ago

Resolved canvas width and height being set to 0

https://github.com/tridecco/game-client-web/commit/204d04c6bc81aa4245aa5bf95b9d351c050772b7

TKanX commented 3 weeks ago

Refactored GameRenderer to use drawBackgroundImage method

https://github.com/tridecco/game-client-web/commit/f4622243fa29df54342a6d8ee8a61cc98b99cef8

TKanX commented 3 weeks ago

Adjusted canvas size dynamically on window resize

https://github.com/tridecco/game-client-web/commit/8749f6acea21cf0145280f7945f997ba8c49f231

TKanX commented 3 weeks ago

Improved rendering performance and structure

https://github.com/tridecco/game-client-web/commit/0a6613f9d863c48cb5229c56f2e8d20332cd66f4

TKanX commented 3 weeks ago

Added methods to draw and clear pieces in Game Renderer

https://github.com/tridecco/game-client-web/commit/6782b6d5975d9cc6457057eabb811cba70859773

TKanX commented 3 weeks ago

Corrected variable name from 'acaleX' to 'scaleX' and 'acaleY' to 'scaleY'

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.

TKanX commented 3 weeks ago

Implemented click event handling piece selection for Game Renderer

https://github.com/tridecco/game-client-web/commit/692333ce8103b0d6584ec2d8af17a2e90bd16632

TKanX commented 3 weeks ago

Load tile images and handle click events in GameRenderer

https://github.com/tridecco/game-client-web/commit/184c6d0cc40dd1aec0b54a30edceb642a6f8d42d

TKanX commented 3 weeks ago

Implemented piece restoration after canvas resize

https://github.com/tridecco/game-client-web/commit/8ee56370b645e8aa73da22b43cee52aaeaefbb0e

TKanX commented 3 weeks ago

Optimized resize handling to prevent excessive calculations

https://github.com/tridecco/game-client-web/commit/baf8760185b8e8b3008e6e3504ddee4d69950e1e

TKanX commented 3 weeks ago

Corrected click position detection by adding canvas rotation

https://github.com/tridecco/game-client-web/commit/e51b9b26f1bf786c9baabf30654a044f34100d3e

TKanX commented 3 weeks ago

Updated drawPiece method to handle flipped tile images

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.

TKanX commented 3 weeks ago

Added default map configuration for game board rendering

https://github.com/tridecco/game-client-web/commit/75cc9077470540bab8422073a644deea470d6869

TKanX commented 3 weeks ago

Image

@tedhyu

tedhyu commented 3 weeks ago

that looks amazing! Is there any plans that once a gem forms to change the image to the hexagon image?

TKanX commented 3 weeks ago

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

TKanX commented 3 weeks ago

Updated _initRenderer method to asynchronously load default map and configuration

https://github.com/tridecco/game-client-web/commit/c498e41feb82cdbd40ff095b36b3747a7593cd9e

tedhyu commented 3 weeks ago

Wow. Thanks for the demo. It looks great.

tedhyu commented 3 weeks ago

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.

TKanX commented 3 weeks ago

Corrected event handling in _handleClick by properly clearing the testing canvas

https://github.com/tridecco/game-client-web/commit/2a0e0f0f928ca470066973064d46a57c6ac8a9eb

TKanX commented 3 weeks ago

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

TKanX commented 3 weeks ago

Optimized testing canvas performance for frequent image data reads

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.

TKanX commented 3 weeks ago

Optimized canvas rendering and improve resize handling

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:

These optimizations enhance the performance and user experience of the game rendering, resulting in smoother gameplay and faster display updates.

TKanX commented 3 weeks ago

Added method to highlight available positions on the board in GameRenderer

https://github.com/tridecco/game-client-web/commit/e522fe0874584bd96e27af11d16ff2e895dd6717

TKanX commented 3 weeks ago

Updated GameRenderer to use flipped tile image for black tiles

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.

TKanX commented 2 weeks ago

Render available positions during player's turn

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.

TKanX commented 2 weeks ago

Added network listener for game:toss event

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.

TKanX commented 2 weeks ago

Added toss button functionality to Game

https://github.com/tridecco/game-client-web/commit/2008f90f7469edc2acfe81590cddacf23cc99346

TKanX commented 2 weeks ago

Restore available positions after resizing the canvas

https://github.com/tridecco/game-client-web/commit/1d352cd04b50a9ea417c1aeeb8f13f73509f7f2b

TKanX commented 1 week ago

Handle piece placement and hexagon formation

https://github.com/tridecco/game-client-web/commit/df95ac48356601427fbda67d6bb5271a027cb472

TKanX commented 1 week ago

Clear pieces on non-first rounds in game round event listener

https://github.com/tridecco/game-client-web/commit/f070d65246fd43b77ca323f434308ccc65a56355

TKanX commented 1 week ago

Resolved issue with piece cache not clearing after round ends, refactor GameRenderer

https://github.com/tridecco/game-client-web/commit/dfec912ffb527fe6ddc9543cf0422d2339b4c17c

TKanX commented 1 week ago

Clean up renderer resources after game ends

https://github.com/tridecco/game-client-web/commit/65dd6c5867b4830b4db8beb0b22f81495e71dc32