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 / Help with bitmaps

Author
Message
Kronos 001
14
Years of Service
User Offline
Joined: 17th Feb 2010
Location:
Posted: 18th Feb 2010 03:55
So, I'm new to all this, and I've only made two programs, first a crappy paint program that used arrow keys and was very slow, second, is what I'm still working on now. It works just fine, but I want to add a background image to the game, so it's there behind everything drawn on the screen.

Video

In the main part where I'm shooting the circles, how would I go about adding a background image there? I tried already, but it flashes nonstop and goes very slow.

Thanks in Advance.

-Teh Nub-
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 18th Feb 2010 06:54
first load your background image. then before drawing all the other things on the screen just past your image to the screen. then when everything else is drawn it will be above that.

New Site! Check it out \/
Kronos 001
14
Years of Service
User Offline
Joined: 17th Feb 2010
Location:
Posted: 18th Feb 2010 22:18
ah sorry, I'm a nub. Can you show me the code to do that? right know I'm just doing:

load bitmap "background.bmp"

which works fine for something with no movement involved. What kind of code would I use for what you're saying? I can't find anything about loading images or pasting images, but I DO remember seeing the command somewhere. Just can't find it again to help me.

-Teh Nub-
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 18th Feb 2010 23:08
You aren't really supplying us with enough information to help you. What we tell you to do to fix it depends a lot on what your program is actually doing at the moment.

What is your program layout?

Do you have a single main Do...Loop with lots of Gosubs inside it?

What type of Syncing are you doing?

Are you using CLS?

That's for starters...

So, making a few assumptions:

1. You don't use Load Bitmap - it's not used for that. Use Load Image instead. (Use F1 for further info on both of them).

2. Use Sync On at the start of your program.

3. Have Sync as the last line at the end of your main Do...Loop.

4. Replace the CLS with Paste Image and put it at the end of the main loop, but before the Sync.

5. Put all the other screen updates at the end of your main loop - between the Paste Image and the Sync.

You should end up with something like this sort of layout:



For more info on Program Layout, see here:

http://forum.thegamecreators.com/?m=forum_view&t=96075&b=7

and for in-game menus, here:

http://forum.thegamecreators.com/?m=forum_view&t=106004&b=10&p=0

TDK

TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 19th Feb 2010 00:21 Edited at: 19th Feb 2010 00:23
You also have the option to texture a locked on plain, but I don't know if that would be too advanced for you... Put this at the start of your code:



It will create a flat square object, and I position that object in the screen so it fills the screen completely. Then I texture the background image on to the plain, and after that you don't have to care at all about your background any more, because it will always be there.

To remove it, use:



TheComet

Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 19th Feb 2010 01:48
I don't think he is using sprites at this point which means he would have to change a lot just to get that when the same effect is achieved from paste image.

New Site! Check it out \/
Kronos 001
14
Years of Service
User Offline
Joined: 17th Feb 2010
Location:
Posted: 19th Feb 2010 03:05
I wish I would have made my program structure better when I first made this, it's so scrambled right now. I know where to go to change things, but wow. I'm trying to get paste image to work. So far, it works better than what I had, as far as it doesn't go slow and flash, but I've only been able to get it to pop up in front of everything, or to load, then go away when it all comes.

What do you mean by replace the CLS with paste image. The cls is at the top of the do loop, wouldn't it just load the image and then everything else would cover it up?

For sync I have "Sync on" at line 1, and I do have sync right before the word loop.

I'm sorry I'm being a pain, I'm sure it'd be easier to help if my program was structured better. Lookit. It's terrible. I know arrays would make that bit better, but sadly, I don't understand arrays either :S



-Teh Nub-
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th Feb 2010 13:43 Edited at: 19th Feb 2010 13:47
Quote: "What do you mean by replace the CLS with paste image."


When you are working with 2D and have things moving across the screen which are not Sprites, then updating the screen involves a CLS then redrawing all the screen objects in their updated positions.

If you don't, they leave trails as they move across the screen.

You wanted a background, so loading it in as an image you can paste it to the screen at 0,0 - to do exactly the same job as CLS did - and then redraw all your other bits on top of the image.

As you didn't supply any relevant sections of your code, I had to assume you were using CLS.

This only works though if you are doing everything in the correct order - which is where the layout of your program is important. If you put every task in it's own procedure or function (stick to procedures for now while you are learning though), your main program loop just consists of lots of Gosubs to each task.

This means that if you call something in the wrong order, you just swap a couple of Gosub lines round in your main loop.

If the section of code you pasted is any indication of the rest of it, I would suggest you don't waste any more time on it until you have a little more experience. As you say, arrays would help a lot here so I suggest that before you do anything else, read tutorials 1-4 here:

http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

You can then start a structured version of your program from scratch - with arrays - and save yourself a lot of headaches... and time in the longrun.

TDK

Kronos 001
14
Years of Service
User Offline
Joined: 17th Feb 2010
Location:
Posted: 21st Feb 2010 18:45
Thanks TDK. I'm still kind of confused with arrays, but my program looks a LOT nicer now, and that background thing works now. It's not done yet, but things are moving on the background and it's not exploding, so I'm not expecting any problems.

One question though, it's not too big of a deal, but is there a way to make the paste image command work right while I have the program running in window mode? At the moment it just doesn't show up. Is it something to do with the position I have it at? It's kinda sad, but my crappy 2d game lags a bit in full screen. [Even though WoW didn't when I played it >.< ] It's not terrible though so if I can't fix it I'm not too worried.

-Teh Nub-

Login to post a reply

Server time is: 2024-04-27 13:50:28
Your offset time is: 2024-04-27 13:50:28