I'm not sure if this is the right area because this is more of an experiment than a request... please read until the end
and put it in the correct area if it is not ..... I already apologize in advance for this.
For those who don't know what raycasting is, it's a technique used in old games to simulate a game with a first-person perspective.
something like we see in wolfstein 3d for example:
<iframe width="560" height="315" src="" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted -media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
the idea came to me when I was messing around with MGC's FPLE ENGINE script (credits to him) which can be found here:
FPLE : First Person Labyrinth Explorer
in this script the camera is in first person but it moves in four directions like in a dugeon crawler game something common in rpgs of the genre:
<iframe width="560" height="315" src="" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write ; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
of course the camera rotates 360 degrees and making the player move smoothly across the map must be a bit tricky
but what if did something more simplified respecting the limits of rpg maker xp?,
I thought of a raycasting script where the character walked respecting the grid of the map, still walking from square to square but instead of rotating at an angle of 90 degrees to four directions (as it is in the mgc script) he rotated the camera at 45 degrees to 8 directions instead of four (and not several as in wolfstein) still respecting the map grid the character could walk diagonally....
Me speaking here seems simple but I know it's not xD, because I'm not good with scripts and it was thinking about that that I thought of having at least one guide for what to do...
the initial concept of raycasting is a ray that sweeps the entire map in search of solid objects...... the ray detects that object and calculates the distance between it and the player in that radius to make the wall approach and disapproach according to the distance:
note that the walls that are actually drawn on the screen in real time are only those that are in the player's view, this allows for high performance
thinking about this concept, I imagined using a tileset for the map, but for this tileset to be identified as a wall or not a wall, I would use the terrain tags:
"0" as not wall and "above 0" as wall. tileset on the map, but it wouldn't do all this movement in /360 degrees smoothly as in the image above, but it would respect the angles imposed by the 8 directions of the rpg maker player ..... it would be something more or less like this in the player's view :
and the player would move like this:
the radius that would scan the map would be created by the script and the distance of the radius between the wall already identified by the terrain tag and the player would be calculated to make the walls move closer or further away
but as i said before i'm not good in scripts...so to be able to help me i used the GPT chat
and I gave him all these parameters mentioned earlier
and it generated me this script:
of course it wouldn't miraculously do all the code for me but when I threw it into my project no error message was received....
but nothing different happened either...
despite everything I think he just gave a base to be able to develop....
as I don't know anything about scripts I wanted to know what you think, and if it is possible to modify it to finally achieve the result
(and no, I don't expect textures right away)
anyway, the code is there for anyone who wants to play with it and see what can be done... thanks in advance and sorry my english
and put it in the correct area if it is not ..... I already apologize in advance for this.
For those who don't know what raycasting is, it's a technique used in old games to simulate a game with a first-person perspective.
something like we see in wolfstein 3d for example:
<iframe width="560" height="315" src="" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted -media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
the idea came to me when I was messing around with MGC's FPLE ENGINE script (credits to him) which can be found here:
FPLE : First Person Labyrinth Explorer
in this script the camera is in first person but it moves in four directions like in a dugeon crawler game something common in rpgs of the genre:
<iframe width="560" height="315" src="" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write ; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
of course the camera rotates 360 degrees and making the player move smoothly across the map must be a bit tricky
but what if did something more simplified respecting the limits of rpg maker xp?,
I thought of a raycasting script where the character walked respecting the grid of the map, still walking from square to square but instead of rotating at an angle of 90 degrees to four directions (as it is in the mgc script) he rotated the camera at 45 degrees to 8 directions instead of four (and not several as in wolfstein) still respecting the map grid the character could walk diagonally....
Me speaking here seems simple but I know it's not xD, because I'm not good with scripts and it was thinking about that that I thought of having at least one guide for what to do...
the initial concept of raycasting is a ray that sweeps the entire map in search of solid objects...... the ray detects that object and calculates the distance between it and the player in that radius to make the wall approach and disapproach according to the distance:
note that the walls that are actually drawn on the screen in real time are only those that are in the player's view, this allows for high performance
thinking about this concept, I imagined using a tileset for the map, but for this tileset to be identified as a wall or not a wall, I would use the terrain tags:
"0" as not wall and "above 0" as wall. tileset on the map, but it wouldn't do all this movement in /360 degrees smoothly as in the image above, but it would respect the angles imposed by the 8 directions of the rpg maker player ..... it would be something more or less like this in the player's view :
and the player would move like this:
the radius that would scan the map would be created by the script and the distance of the radius between the wall already identified by the terrain tag and the player would be calculated to make the walls move closer or further away
but as i said before i'm not good in scripts...so to be able to help me i used the GPT chat
and I gave him all these parameters mentioned earlier
and it generated me this script:
Ruby:
#-------------------------------------------------------------------------------
# Wolf3D-style 8-directional walls script for RPG Maker XP
# by ChatGPT
#-------------------------------------------------------------------------------
# Constants
WALL_TAG = 1
SCREEN_WIDTH = 640
SCREEN_HEIGHT = 480
GRID_SIZE = 32
# Wall drawing function
def draw_walls
for x in 0...$game_map.width
for y in 0...$game_map.height
# Get the distance from the player to the current tile
dist_x = ($game_player.x - x) * GRID_SIZE
dist_y = ($game_player.y - y) * GRID_SIZE
# Check if there is a wall in the tile
if $game_map.terrain_tag(x, y) > 0
# Check the direction of the wall based on the distance from the player
if dist_x.abs > dist_y.abs
if dist_x > 0
# Wall is to the right
$game_map.set_tile(x, y, wall_right_tile_id)
else
# Wall is to the left
$game_map.set_tile(x, y, wall_left_tile_id)
end
else
if dist_y > 0
# Wall is to the bottom
$game_map.set_tile(x, y, wall_bottom_tile_id)
else
# Wall is to the top
$game_map.set_tile(x, y, wall_top_tile_id)
end
end
else
# No wall, so use the empty tile
$game_map.set_tile(x, y, empty_tile_id)
end
end
end
end
of course it wouldn't miraculously do all the code for me but when I threw it into my project no error message was received....
but nothing different happened either...
despite everything I think he just gave a base to be able to develop....
as I don't know anything about scripts I wanted to know what you think, and if it is possible to modify it to finally achieve the result
(and no, I don't expect textures right away)
anyway, the code is there for anyone who wants to play with it and see what can be done... thanks in advance and sorry my english