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.

DarkBASIC Discussion / Drawing rectangles to the screen

Author
Message
demons breath
22
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 16th Oct 2007 14:41
The code below uses a function which I made the other day for drawing rounded rectangles to the screen. It should draw one big green rectangle and then 4 small ones, however although it initially worked with the large green rectangle, the addition of the four smaller has been somewhat problematic. In fact, I have been met with little success at all; for some reason, which I find myself completely at a loss to ascertain, the program will only draw one small, grey rectangle to the screen. I find myself unsure of how to continue and decided to resort to these forums in my attempts to progress with my aim.

Thank you for your time and any input you may have upon this, my most perplexing problem...



http://jamesmason01.googlepages.com/index.htm
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 16th Oct 2007 15:16
Hi demons breath,

In your DrawTypeList() function, you don't have any reference to your Global race definition variables so the function's loop isn't able to cycle through them. You have to pass some parameters to the function so it knows the values of the race variables. Here's one suggestion for how the function could look:



And you would call it like this:

DrawTypeList(rHuman,rDwarf,1)

Enjoy your day.
demons breath
22
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 16th Oct 2007 15:28 Edited at: 16th Oct 2007 15:33
hmm... well that was foolish... but nevertheless if I just replace it with


or put that in the main loop it still comes up with a problem.


EDIT: OK now the square is the rightmost one. That implies that the problem is in the "copying one bitmap to another" style bit of the MakeRoundedBox function... but this shouldn't be a problem as in my test programme running the function this it still worked fine

with








OH WAIT! syncs! it's trying to copy the screen, but without the sync command to update it beforehand there's nothing to copy...

I feel a little foolish now - my only sync is after everything should have been drawn but obviously that won't work...

http://jamesmason01.googlepages.com/index.htm
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 16th Oct 2007 23:28
@Demon
You might find this useful, it's an example of a recursive function.
http://forum.thegamecreators.com/?m=forum_view&t=110907&b=6

demons breath
22
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 16th Oct 2007 23:31
Hahaha you're always posting links on every thread you read

But yeah that's a cool function

http://jamesmason01.googlepages.com/index.htm
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 16th Oct 2007 23:36
Here's another way of doing a rounded box - a little faster, but not that much...

It can also create rounded boxes on any colour background.

The Function:



Example Of Using It



TDK_Man

demons breath
22
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 16th Oct 2007 23:51
Yeah I saw your rounded box function on TGPF earlier today, but I've already made mine so...

http://jamesmason01.googlepages.com/index.htm
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 17th Oct 2007 00:16
No obligation...

I didn't try your function, so I wasn't sure if it would work on a screen coloured differently to the background colour you use for the rounded box. (All the examples I've seen before didn't).

TDK_Man

demons breath
22
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 17th Oct 2007 01:25
The background colour is like the main colour of the rounded rectangle

The foreground is an outline

It copies the entire screen to a new bitmap, draws a box from (x1,y1) to (x2,y2) with a rounded corner (you choose the size), with a border of an integer amount of pixels which you choose coloured a colour you choose, and the main part is a different colour, which you choose, unless you want the rounded rectangle to be see-through. It then pastes it to your bitmap of choice.

It can do a lot, but for simple stuff it's probably overkill... I'm trying to make loads of little, re-useable things at the moment because I have one aim in mind, which I doubt I will ever start on, but I'm working my way up to a re-useable library of functions. That being my first ever function, I still have a long way to go, but... it's a start at least...

http://jamesmason01.googlepages.com/index.htm

Login to post a reply

Server time is: 2026-07-07 08:08:23
Your offset time is: 2026-07-07 08:08:23