[SOLVED] Wide sprite to face right direction.

Started by Nickydude, Mon 29/03/2010 17:39:09

Previous topic - Next topic

Nickydude

Hi Guys,

I'm creating a scuba diving type game and all is going well but I have two problems. Take a look at this image.



The first problem that I have is that I want the diver not to go over the 'black rocks'. I've created a walkable area around the rock



But I don't want any part of the diver going over the rock.



The second problem is that when going up or down, how to I turn the diver to face either left or right where the player clicked? At the moment the diver faces one way going up and one way going down so sometimes he can go backwards, which I don't want.

Any help would be appreciated. :)
Best Regards,
Nickydude
www.madladdesigns.co.uk

AGS Beginner's Guide - All you'll ever need!

barefoot

#1
Hi

If you dont want the diver to be shown going 'over' the black rocks and have your Walkable area set then you should use a 'Walk behind' area that covers ALL the black rock area, adjusting it's Baseline as required.

If you want the Diver to go behind the Black Rock then the Walk Behind is essential.

You need to make Views for your diver such as UP, DOWN, LEFT, RIGHT (Athough UP could be flipped for DOWN and LEFT could be flipped for RIGHT etc etc).

Make sure your Views reflect the direction its intended for.

I see you have diver going LEFT, simply select the RIGHT View, select Diver Image and flip it.




Hope this is helpful

barefoot

I May Not Be Perfect but I Have A Big Heart ..

Nickydude

Hi barefoot, thanks for replying.

1/. I don't need the diver to go behind the rocks, just stop so he doesn't go over them.

2/. I already have up and down views but if the diver is, say, in the middle of the screen and I click top left he goes up facing left, but if I click top right he goes up to the top right still facing left as that's the view for up. I need him to turn to the correct direction before going up, down.
Best Regards,
Nickydude
www.madladdesigns.co.uk

AGS Beginner's Guide - All you'll ever need!

barefoot

#3
Hi

Then you should make the Walkable area fall short of the rocks so he does not go onto them. Adjust Walkable area until you are happy.

If you click top right it will assume you are going right and will face right, if you click top left then it will assume you are going left and face left. Of course diagonal views would be better.

You need to check its Views are facing in the direction they should be.

barefoot
I May Not Be Perfect but I Have A Big Heart ..

Khris

1. With characters, the pivot is at the bottom center of the sprite. If you set the diver's .z to something like -20 or so, you can move it to the sprite's center.
Then use a paint program to select all the water using the magic wand and move the selection to the right a good deal, roughly half the diver sprite's width. Now fill the selection using green or something, delete everything else and import it as walkable area mask (I believe you need to reduce the colors to 256, then save it as PNG for best results).

2. One solution is to use two views. One has the diver facing left in its up and down cycles, the other has him facing right. After a walkto-click, check if mouse.x > diver.x and set the right-facing view as normal view if true, the other one if false. Then proceed as usual (process click / player.Walk).

(Note that this method will only work for big, contiguous areas, not maze-like ones.)

Nickydude

Thanks Khris,

I'm not really understanding point 1 there at the moment but the second point sounds interesting, so i can say "if the pos of where the mouse has been clicked is greater than the divers x pos then display one view, else display another view? How would I go about that? Where would I put it? In all of the room scripts?
Best Regards,
Nickydude
www.madladdesigns.co.uk

AGS Beginner's Guide - All you'll ever need!

Khris

#6
1. Here's the map:


(right-click, Save Image As...)

2. In on_mouse_click, after if (button == eMouseLeft) {

Code: ags
    if (mouse.Mode == eModeWalkto) {
      if (mouse.x > player.x) player.ChangeView(RIGHTVIEW);
      else player.ChangeView(LEFTVIEW);
    }
    ...


I don't know if your game is diving only, so if it isn't, add a check for player.Room.

EDIT: Code correction.

Nickydude

Thanks Khris. :D

I've added you code:

Code: ags
else if (button == eMouseLeft) {
    ProcessClick(mouse.x, mouse.y, mouse.Mode );
    if (mouse.Mode == eModeWalkto) {
      if (mouse.x > player.x) player.NormalView = 2;
        else player.NormalView = 1;
    }
  }


and changed the views to the appropriate number (is that right?) but it's giving me an error and telling me that player.NormalView is read-only.
Best Regards,
Nickydude
www.madladdesigns.co.uk

AGS Beginner's Guide - All you'll ever need!

Khris

Right, sorry, you have to use player.ChangeView(x);

Nickydude

#9
Right, thanks again :)

But there's now another problem (sorry :(). I have 1 view  with 4 loops, up, down, left & right and each one of those 'loops' is just a single image so how do I pick a particular loop from that one view?



Sorry for all the questions but I'll know for next time. :)
Best Regards,
Nickydude
www.madladdesigns.co.uk

AGS Beginner's Guide - All you'll ever need!

Khris

Like I said:
Quote from: Khris on Mon 29/03/2010 18:54:13
One solution is to use two views. One has the diver facing left in its up and down cycles, the other has him facing right.

So in view 1, it's left, left, right, left
in view 2, it's right, left, right, right

The thing is that you can't pick a particular loop, and that's precisely why you have to use two views and alternate between 'em.

Nickydude

#11
Right, got you now, thanks for your patience Khris, here have a thank you. :)



Works perfectly.
Best Regards,
Nickydude
www.madladdesigns.co.uk

AGS Beginner's Guide - All you'll ever need!

SMF spam blocked by CleanTalk