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.

Code Snippets / [DBP] - Make sprite buttons on the fly with a simple function call

Author
Message
jestermon
12
Years of Service
User Offline
Joined: 26th Nov 2010
Location:
Posted: 27th Nov 2011 15:44
DarkBasic Pro is certainl a lot of fun.
After being used to managing 2D buffers in Pygame, it is a delight to find a 2D/3D engine that has the same kind of power.

Here's a conversion of one of my Pygame functions to DarkBasic, that generates buttons on the fly, with a single function call. Instead of creating image buttons in an image painter, the game or simulation can make it's own buttons 'on the fly' whenever they are needed.

Enjoy.

Zotoaster
17
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 27th Nov 2011 23:59
You should make it generate it's own sprite and image numbers and return the sprite number.

You should also have a function that checks the state of the button, e.g., ButtonClicked(spriteNo) that returns true or false.

"everyone forgets a semi-colon sometimes." - Phaelax
MrValentine
AGK Backer
11
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 29th Nov 2011 12:08
Nice... thanks for sharing...

Brought back memories of some old games...

You should add this to the codebase too.

Login to post a reply

Server time is: 2022-11-30 13:44:16
Your offset time is: 2022-11-30 13:44:16