Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / menu code done with sprites

Author
Message
Cyril Grey
19
Years of Service
User Offline
Joined: 28th Jan 2005
Location:
Posted: 1st Aug 2005 05:11 Edited at: 1st Aug 2005 05:32
Here is a screen shot and the code I wrote for my menu screen. I thought it might come in handy for someone out there...



With math all things are possible

Attachments

Login to view attachments
Heckno
20
Years of Service
User Offline
Joined: 8th Sep 2004
Location: Palm Coast, FL
Posted: 1st Aug 2005 06:35
looks great, I need a menu screen...one of these days -sigh-
NanoBrain
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 1st Aug 2005 07:13
Cyril Grey,

Nice graphics. The image has a good eery feel to it.


+NanoBrain+
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 1st Aug 2005 08:43 Edited at: 1st Aug 2005 08:44
Wow! Nice menu! It's always nice to see good artists with programming talent too.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Aug 2005 11:55 Edited at: 1st Aug 2005 11:55
Nice looking menu.

Do you know you can use sprite collision to detect which option has been clicked? Use a small, 2 pixel sprite, hidden, which is positioned at the mouse coordinates. Do your collision checking against this sprite and the menu sprites.

The beauty of this approach is that you can move your menu around or redesign it, and the code still works.

NanoBrain
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 1st Aug 2005 12:45 Edited at: 1st Aug 2005 12:47
Cyril Grey,

I was in the mood to teach you a more effecient way to code the collision checking system. Therefore, below is a snippet of your edited code. It makes use of the height of each sprite, so that you don't have to code in the height values yourself. It saves whitespace and your time.




+NanoBrain+
Cyril Grey
19
Years of Service
User Offline
Joined: 28th Jan 2005
Location:
Posted: 1st Aug 2005 15:02
Thanks for the positive feedback, and thanks Nano for showing me the more efficient way to detect collision. I did find one small problem: in the else statement z+1 should just be z. Also, if you have an item highlighted and move to the left or right (still within the height of the sprite) the sprite doesn't change back to alpha 150. If fixed the problem by setting the alpha to 150 each time the sprite is drawn and only to 255 if the mouse is ont he sprite:



Thanks again!!

Cyril

With math all things are possible
NanoBrain
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 1st Aug 2005 21:56
Cyril Grey,

Whoops. I forgot to add that line in. Below is the updated code.




+NanoBrain+

Login to post a reply

Server time is: 2024-11-27 20:50:25
Your offset time is: 2024-11-27 20:50:25