Raycasting 3D render -- Blocks Edition

Here it comes finally.
It took me several days to find out how raycasting render would work with existing blocks/functions and Arcade game platform together. After read many source codes to try to inject my codes in, the last supposition worked. That is take over tilemap’s renderable instance and all sprites created in current scene to prevent them from being drawn, and keep them in physical engine to make overlap things happen at meanwhile, and then register frameHandlers to draw tilemap and update&draw sprites.
Let me know pls, if there is a more proper/elegant way.
Also need suggestions to impove, really appreciate!

Demo project:

Extension URL (v0.3.2 or above)

https://github.com/AqeeAqee/pxt-raycasting

Brief:

An extension for Makecode Arcade, render a tilemap into raycasting 2.5D view(a kind of less calculation consuming 3D perspective view mode), with directional animations of sprites,

based on mmoskal’s 3d map

Quick Start

  • Basically, this render just draw a traditional tilemap game into “3D view”
  • setTilemap(), walk around with arrow keys
  • Do your game as usual
    • sprites, suggest sprite.setScale(0.5) for each, set directional animations with provided animation block.
    • work together with most of Arcade blocks and extensions, sprite, projectile, overlap,…
    • except these drawing screen directly, sprite effects/saytext …
  • Operate view pos and collision size with provided “myself sprite”, and view direction with “setViewAngle” block
  • Switch view mode with block “setViewMode to tilemap(2D)/raycasting(3D)”
  • Zoom in/out by set fov
More ...

Known issues:

  • Performing: To compactible with existing blocks, many codes are added in, the perf goes down significantly, need tuning later.
  • The Arcade phyical engine worked fine if sprite image is square. But if not, say a tall tree, collision will occured before hit the wall at y axis.
    • Reason: The physical engine working in 2D mode, that consider sprite image as its size(x&y direction). But 3D render consider the image width as size for both x & y axises, height as sprite Z-axis size. This could be fix by override the physical engine, in future, if needed.

Todo:

  • Sprite sayText, particles, effects
  • Override physic engine.
  • Perf tuning, Fx8
  • Pose depended animations, stand, walk, attack. Any one need?
  • function/block for disable controller codes in this extension, so user can control “myself” in user code
  • Tutorial
16 Likes

You could use the sprite’s “bottom”, “top”, “left”, or “right” anchors, so it wouldn’t matter what size the sprite was. Just an idea, instead of coding a new physics engine. (IDK if I fully understand the above quote, but I think this might work)

1 Like

this is AMAZING i can do so much with this but just wondering is there a way to make the myself sprite jump or have a character in front cause with this i could make maze games snic robo blast 2 or super mario 64 or even some type of minecraft like game if you can add layers onto this

thanks for creating this :grinning:

2 Likes

Thanks @Kiwiphoenix364 for your suggustion !
The sprites top,left,right,bottom are critical for collision. They all are “mapped” into hitbox when create, with which physical functions calculate , and it will be “re-map” every time setImage(). So user need notice extension to update hitbox every time after set a new Image (need user learn more about this extension). I will try to dig deeper to find whether this can work. If yes, it still need a balance between simple implement and easy learning(convenience).
Thanks again for providing me more idea, very appreciated!

1 Like

Wow, this looks great, thanks for sharing.
I will try to understand how this works and add some protagonists to my 3D experiment:

8 Likes

This is incredibly cool, great job :smiley:

3 Likes

yes, jump maybe possible, but be aware it’s not “jump on” to some cube or platform, cause infact every cube have no top/bottom surface. :joy:

yes, I should say sorry for this, it’s a bug, that sprites with flag “relative to camera” are tookovered too by my render, so they would not be drawn as HUD alike.
Check out new release please (v0.3.3). (to update:In your game, goto JS mode and press refresh button next to the name of my extension in files list at leftside)

1 Like

Wow, really cool!
You made walls alive, that make me to think to add ani feature for wall textures too.

Feel free to let me know if you have any question on it, or let’s discuss what features/interfaces need to make this kind of 3D render better.

1 Like

Wow! This is really cool!

1 Like

SayText featrue preview

It works, but I didn’t release new version yet, cause I am not sure about following:

  • need show say in 2d? No add to 2d map yet, many saying text make 2d map kind of mess I think.
  • only show saytext when center of sprite in screen? Right now, shown as long as any part of sprite shown.
  • issue: can’t be covered by walls/sprites by now, it will invovle many calculation, really need?
    What do you think about these?
7 Likes

Another preview edtion

  • add wall scale
  • add jump, via selfSpr offsetZ as view point height
  • btw, other sprites can also “jump” with it’s offsetZ
10 Likes

Wow, thanks AqeeAqee, wall scale and jump are great additions :slight_smile:
It runs very well on Meowbit hardware,

2 Likes

Will it be in blocks?

1 Like

Good new !
So happy you like it!
And waiting for your project with it!

1 Like

Definitely yes!
Blocks for all functions is one of my basic principle when building this extention ( as far as I can :joy: )

2 Likes

Okie Dokie

1 Like

yo this is awesome

2 Likes

Do you think you are ever going to create strafing?

1 Like

Yep, it is if you fire fast enough :smile:
Have fun!

1 Like

Well that makes sense :laughing:. I meant, is there any official way to enable side-to-side movement?

1 Like