Advanced Features in TCJSgame

TCJSgame provides many advanced features that allow developers to go beyond simple object creation and movement. These features help in creating more dynamic, optimized, and professional-quality games. While beginners can focus on components and physics, advanced users can take advantage of custom rendering, angle-based movement, smooth camera following, and procedural tile manipulation.

Angle-Based Movement

Normally, components move by updating speedX and speedY. However, the moveAngle() function lets you move based on an angle, making it easier to implement rotation-based physics such as vehicles, bullets, or rotating objects.


player.angle = Math.PI / 4; // 45 degrees
player.speedX = 3;
player.speedY = 3;
player.moveAngle();
    

Smooth Camera Following

The Camera class can follow a target, either snapping directly or moving smoothly with interpolation. This allows you to create side-scrolling or open-world maps where the view tracks the player.


display.camera.follow(player, true); // Smooth follow
    

Dynamic TileMap Editing

Tile maps are not fixed; you can add, remove, or replace tiles during gameplay. This makes it possible to build destructible terrain, place items dynamically, or generate levels procedurally.


// Add tile at position (x=5, y=3)
display.tileFace.add(2, 5, 3);

// Remove tile at (x=2, y=1)
display.tileFace.remove(2, 1);
    

Custom Utilities

You are not limited to the built-in move and state utilities. Since TCJSgame is written in plain JavaScript, you can extend it by writing your own helpers that operate on components or the display context. This allows you to build custom mechanics such as homing missiles, health systems, or particle effects.

Note: Advanced features are optional, but they unlock the full potential of TCJSgame. Start small, then gradually introduce these techniques to add polish and complexity to your projects.