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 Professional Discussion / A question about GET IMAGE

Author
Message
Rwilson
23
Years of Service
User Offline
Joined: 19th May 2003
Location: United States
Posted: 28th Oct 2003 17:05
Right now, I'm using the following code to create a toolbar on my screen.



My question is based around the fact that, from what I remember, the GET IMAGE command can cause a FPS drop in certain cases. So as to prevent possible problems later in the program, I am asking as to whether or not this is true, and if so, how one can create a toolbar sprite without it.

Usermlsra - Causing Havoc with a Smile
skovron
22
Years of Service
User Offline
Joined: 14th Sep 2003
Location:
Posted: 28th Oct 2003 17:44
Well not sure if i am corect but get/put image decreases fps when are being used many times in every loop. when you once get some image and use it as a sprite its not so hard to handle for a computer. ofcourse you shouldnt use a lot of sprites at once.
The main reson for such a situation is that M$ dont support Direct Draw anymore (since DirectX 8 propably). They say that everything should be done using 3D. So using DirectX 8/9 its better to render some planes with textures than drawing images.

[sorry for my english and forgive me if sth i said is not true]
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 28th Oct 2003 17:54
GET IMAGE is incredibly slow, well maybe that's an exageration, but it's not the sort of thing you want in your main loop. Your code is GETting the image then creating a sprite from it, this is a nice and neat way to work, because you don't need to do anything else - just maybe a highlight sprite for when you click a button, but there's nothing wrong with what your doing now.

Stick to sprites, maybe even look into setting the alpha on the sprite so that it's translucent, or even translucent until you move the mouse onto it - there's a couple of neat little tricks you can do (just check out the switchblade file browsers in VSD Tracker ). One thing to remember though, is that any paste image or any 2D operation will appear behind the sprite, so a translucent sprite with a green filled box in the same position will show as the sprite with a green tint.


Van-B

Rwilson
23
Years of Service
User Offline
Joined: 19th May 2003
Location: United States
Posted: 28th Oct 2003 19:02
That could be a problem, Van B. The Game I'm making is (eventually) going to be a Simcity-esque gmae, thus meaning a continually running loop. And I was planning to put your money amount on the ToolBar, which would put Get Image in the main loop. Yeah, Uh Oh. So, do you know of any ways of mimicing Get Image in a faster way? Or perhaps a command I havn't heard of?

Usermlsra - Causing Havoc with a Smile
Codger
23
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 29th Oct 2003 03:16
Make it a function and only call it when "your money" changes
If Money <> OldMoney Then UpdateMoney()

Function UpdateMoney()
set current bitmap 1
paste image MB,0,0
text 39,249,"Mouse X" + str$(mousex())
text 39,259,"Mouse X" + str$(mousey())
get image 6,0,0,199,767
set current bitmap 0
sprite 1,1,1,6
OldMoney = Money
EndFunction

System
PIII 650 MZ H.P. Pavillion
394 Mem GeForce 4 400MX
Rwilson
23
Years of Service
User Offline
Joined: 19th May 2003
Location: United States
Posted: 29th Oct 2003 06:17
That's a good idea! Thats proboly how I'll go about doing it, so thanks a lot, Codger! All the help is appreciated!

Usermlsra - Causing Havoc with a Smile
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 29th Oct 2003 10:12
An option is to make a bitmap with your toolbar on it, which you could draw onto without affecting the main screen, then every loop, you simply copy the bitmap into place. Like:

Do

`When money changes or something else on the toolbar changes
if mouseclick()=1 then updatetoolbar()

copy bitmap 10,0,0,640,16,0,0,0,640,16
sync
Loop

Function Updatetoolbar()
set current bitmap 10
paste image 1,0,0
text 40,3,str$(money)
set current bitmap 0
endfunction

BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 29th Oct 2003 10:40
I make my toolbars out of multiple sprites, set the priority of the bar to 0, and the priority of everything on it to 1. This way, you're only dealing with small portions at a time.

I also cycle the updates, so each element is updated say once every 5 cycles (0.1 seconds at 50FPS).

BatVink (formerly StevieVee)
http://facepaint.me.uk/catalog/default.php

Login to post a reply

Server time is: 2026-07-26 16:04:11
Your offset time is: 2026-07-26 16:04:11