Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

Guest Anonymous Poster

Picking up items a la UO, U7, etc.

This topic is 6946 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I never played Ultima, but there are 3 ways.

1) You create a simple box around this item, it doesn't matter if he clicked one pixel from the item. That's the easiest and fastest way.

2) Use more than one of these boxes around the items, so you can get it work with many different shapes.

3) Use the alpha with the item white and the rest black and have it in the memory. If you click on some white stuff, he got the object. This method needs much memory and is slow compared to no. 1 or no. 2.

IMO method 1 should be the one you normally use, if you do not need it for something special. You will have less problems and more memory than using method 3. Method 2 is also useful if you go many different shapes, so you can have a circle item for example.

/ \
| |
\ _ /

In the first method, you have only one box around, like this :

| _ |
| / \ |
| | | |
| \ _ / |

This would work, but you could click on some characters which are near the item and you get the item and won't talk to the characters.

|/ \|
| |
|\ _ /|

It's a bit ugly to show this using ASCII-art, but I don't wanna create some jpeg's or something else. I hope you unterstand what I mean. Here is one better example :

| | |
| |-------|
| |

Normally you would have big overhead in the rectangle, but you can create 2 rectangles and it works perfectly. You can do this with as many rects as you want and get it work with every object


Skullpture Entertainment

[This message has been edited by NuFAN (edited September 18, 1999).]

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
I really like the way Ultima Online and Ultima 7 handle moving of items. Simple drag and drop. Can anyone refer me to any tutorials of how I might go about handling this? I guess the one thing I don't understand how to do is detecting if the user clicked exactly on the object, or if they missed 1 pixel to the left and clicked on some grass. How do you calculate if the user clicks on a non-rectangular/square object?

Share this post

Link to post
Share on other sites
You can read on how to do pixel-perfect object selection at www.xyphus.com/users/dino (under the Technical section). The basic idea is simple.

As you draw your images, you will store in a list somewhere the rectangle that bounds the image. When trying to determine if a point is over a specific object, you traverse the list _backwards_. If the point is within the bounding rectangle, you then check to see if the pixel is over a non-transparent portion of the image. This can be done a few way and it's really up to you. If the point is over a transparent portion of the image then you continue searching the list.

This method is pretty damn fast. It rivals NuFan's method, although it is a tiny bit slower.

Good Luck.

Dino M. Gambone

Good judgement is gained through experience. Experience, however, is gained through bad judgement.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!