Display a FlipBook Or Something in Isometric View
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Display a FlipBook Or Something in Isometric View
Is it possible to make a Crosshair in the isometric view using a flipbook and a script...or oly a script. This week I'm working on a mini game, where you have a top view and this is made by an isometric camera, but I need a crosshair so I will be able to see where am I shooting.
Look at this post in my website (it's translated by google), that's what I'm talking about, see the screens
http://translate.google.com/translate?u ... n&ie=UTF-8
Look at this post in my website (it's translated by google), that's what I'm talking about, see the screens
http://translate.google.com/translate?u ... n&ie=UTF-8
Re: Display a FlipBook Or Something in Isometric View
If it's a top down perspective it is - relatively to a 3d or isometric view - simple. The middle point of the image has to be calculated using the sin and cos functions with the angle of the player and a given distance from the player. Then add the position of the player on screen.
The YAW_DELTA value depends on which value the yaw value has when the player is facing right. The goal is to make the number inside the sin and cos functions 0 if the player is facing right. If the player is already facing right when self.player_yaw is 0, then it should be 0. Normally the YAW_DELTA_VALUE should be a multiple of Pi/2. This is because 2*Pi equals a full circle, like a compass, in which 0 and 2*Pi are east. The Pi/2 would be north, Pi would be west, and 3/2*Pi would be south (or -Pi/2). The only sure way is to try it out. First use those four numbers - 0, Pi/2, Pi, -Pi/2 - as the YAW_DELTA value and then if it does not work you can go to stranger numbers.
But this will ONLY work if the view is 100% top down view. If it is only slighly isometric it would look unrealistic. If you want to use it in any camera angle possible, it will get VERY complicated, because then you will be doing some extensive 3d math - the very same the computer does for every vertex in a 3d scene.
Code: Select all
IMAGE_MIDDLE_X = PLAYER_SCREEN_POS_X + sin(self.player_yaw+YAW_DELTA)*CROSSHAIR_DIST;
IMAGE_MIDDLE_Y = PLAYER_SCREEN_POS_Y + cos(self.player_yaw+YAW_DELTA)*CROSSHAIR_DIST;
IMAGE_TOPLEFT_X = StringCopy(IMAGE_MIDDLE_X) - IMAGE_SIZE_X_HALF;
IMAGE_TOPLEFT_Y = StringCopy(IMAGE_MIDDLE_Y) - IMAGE_SIZE_Y_HALF;
But this will ONLY work if the view is 100% top down view. If it is only slighly isometric it would look unrealistic. If you want to use it in any camera angle possible, it will get VERY complicated, because then you will be doing some extensive 3d math - the very same the computer does for every vertex in a 3d scene.
Everyone can see the difficult, but only the wise can see the simple.
-----
-----
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Re: Display a FlipBook Or Something in Isometric View
Code: Select all
[Isometric]
; camera height above ground (in texels)
; auto adjusts height to current player actor
height = auto
; angle (in degrees) of camera above horizontal
angleup = 89.9
; angle (in degrees) of camera from directly behind
anglearound = 0
; distance (in texels) of camera from player
distance = 350
; if true the camera will move in/out to avoid obsticles
collisiondetection = true
Re: Display a FlipBook Or Something in Isometric View
With unrealistic i meant it was not 100% realistic. Maybe i exaggerated a bit here. Try it with 89.9, it should work too, i meant like an angle of 85 would produce a bit unrealistic results.
If you just display the mouse you get the problem that you then have to calculate the point where you have to shoot and this would be just as, if not more complicated.
If you just display the mouse you get the problem that you then have to calculate the point where you have to shoot and this would be just as, if not more complicated.
Everyone can see the difficult, but only the wise can see the simple.
-----
-----
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Re: Display a FlipBook Or Something in Isometric View
well, in the top down view, the player is rotatet by the mouse, the problem is that the crosshair is gone.
OK, so theese commands are in low-level, and I'll have to use a flipbook for this, right?
OK, so theese commands are in low-level, and I'll have to use a flipbook for this, right?
Re: Display a FlipBook Or Something in Isometric View
I know this ain't exactly what you're after but I just have to post it. This little script draws a crosshair on the screen and lets you move it freely around the screen with the mouse. Then it calculates the angle between the crosshair and the player origin and rotates the player accordingly. Works with the built-in player:
You'll need a flipbook called 'crosshair' in your level that contains the crosshair bitmap. It should be 32x32 pixels. For a different size you'll need to change the line
so that XX is half of the image's width and YY is half of its height.
Code: Select all
{
deltaX [0]
deltaY [0]
angle [0]
Spawn[ ()
{
LowLevel("setup");
} ]
setup[ ()
{
PawnRender(false);
MouseControlledPlayer(false);
think = "run";
} ]
run[ ()
{
deltaX = GetEntityScreenX("Player") - GetMousePosX();
deltaY = GetEntityScreenY("Player") - GetMousePosY();
if(deltaY = 0)
{
deltaY = deltaY + 0.1;
}
if(deltaY > 0)
{
angle = atan(deltaX / deltaY) / 0.0174532925199433 + 180;
}
else
{
angle = atan(deltaX / deltaY) / 0.0174532925199433;
}
DrawFlipBookImage("crosshair",0,GetMousePosX()-16,GetMousePosY()-16,255,0,0,0,1);
SetEntityRotation("Player",0,angle,0);
} ]
}
Code: Select all
DrawFlipBookImage("crosshair",0,GetMousePosX()-XX,GetMousePosY()-YY,255,0,0,0,1);
Pain is only psychological.
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Re: Display a FlipBook Or Something in Isometric View
Code: Select all
if(deltaY > 0)
{
angle = atan(deltaX / deltaY) / 0.0174532925199433 + 180;
}
else
{
angle = atan(deltaX / deltaY) / 0.0174532925199433;
}
and the crosshair is not displayed.run 14/10 atan Method not found
I changed the line :
Code: Select all
DrawFlipBookImage("crosshair",0,GetMousePosX()-16,GetMousePosY()-16,255,0,0,0,1);
Code: Select all
DrawFlipBookImage("crosshair",0,GetMousePosX()-90,GetMousePosY()-90,255,0,0,0,1);
I named the flipbook "crosshair" and everything else should be just fine, but the crosshair doesn't show up and the player won't rotate if I'm using the script. Maybe I've done something wrong again.
oh btw, can you explain me what is this about
Code: Select all
angle = atan(deltaX / deltaY) / 0.0174532925199433 + 180;
Re: Display a FlipBook Or Something in Isometric View
Which RF version are you using? The atan command is only available in 0.76 and so this script will only work with that version.
Basically:
<angle in radians> / 0.017... = <angle in radians> * 57.295... = <angle in radians> / (2 * PI) * 360 = <angle in degrees>
Then it should be:because my flipbook image is 90X90.
Code: Select all
DrawFlipBookImage("crosshair",0,GetMousePosX()-45,GetMousePosY()-45,255,0,0,0,1);
That's just the conversion from radians to degrees. The digits are there so the value is exact enough.and why there are so many digits here, I got a little confused
Basically:
<angle in radians> / 0.017... = <angle in radians> * 57.295... = <angle in radians> / (2 * PI) * 360 = <angle in degrees>
Pain is only psychological.
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Re: Display a FlipBook Or Something in Isometric View
oh, I'm making the game with 0.75, I'll update to 0.76 and see if it works, thanks!
Re: Display a FlipBook Or Something in Isometric View
Thanks Juutis. That script does exactly what i was trying to do, but didn't have the time to dive depper into the code. I was aiming for something like a point and click in isometric view, like diablo. I have to rewrite it for isometric view and not only top-down, but this is a good start. Thanks!
Everyone can see the difficult, but only the wise can see the simple.
-----
-----
Re: Display a FlipBook Or Something in Isometric View
Jay, it seems you agree with me on one thing....isometric is the BEST for rpg's........and thanks juutis!
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Re: Display a FlipBook Or Something in Isometric View
Yeah baby, it works GREAT! Thanks, man!
Now I have some problems with the new version (again), but I think I'll be just fine. The player moves alfuly fast and nothing slows him down, because of that, he can walk through everything and even get out f the level . But let's don't get off-topic, thanks again!
I think this thread should be one of the top threads, because a lot of people would want something like this in their games, and here the problem is solved.
Now I have some problems with the new version (again), but I think I'll be just fine. The player moves alfuly fast and nothing slows him down, because of that, he can walk through everything and even get out f the level . But let's don't get off-topic, thanks again!
I think this thread should be one of the top threads, because a lot of people would want something like this in their games, and here the problem is solved.