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 / Clearing the screen - should be simple

Author
Message
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 5th Feb 2007 09:38
I have been able to eventually figure out all the 2D and 3D commands and understand that there is a difference between 2D and 3D screens.

However, I can't seem to be able to figure out how in the world to clear the screen of simple 2D objects. CLS does not work.

I had basically finished a 2D arcade game as a hands-on project for learning DBP. I then wanted to add just a simple "title" screen prior to game start. I loaded 4 images and used the paste image statement. I also loaded and played 1 sound file (wav). Two of the images were a help button and a play button. When I click on the play button it continues with my program as it was coded and the screen is changed to the game area (all 2D) and everything is fine.

When I click on the help button, I have not been able to clear the screen of those initial images so that it is a blank canvas for my help stuff. I thought a simple CLS would suffice but that does not work. In fact I actually didn't need it for the game area. I tried emulating what I had done to init the game area even to the point of loading and pasting the background image. That didn't work.
The original images remained. I made sure that I had code that would keep me in the help area until the space-key would be pressed (for testing purposes). When I would press that key it would go ahead and start the game which again works just fine. I do not know what I am missing or not doing or whatever.

The following is the code which is not optimized as yet. Also I had redone the logic and sequences of some of the code to see if that would make any difference. None had and this code reflects the last changes so they may seem a little odd.




Any help of course would be appreciated. I may find it myself tommorrow after I've had some sleep.

As opposed to Highlander.
Mr X
19
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 5th Feb 2007 10:17 Edited at: 5th Feb 2007 10:19
I don't understand your code entierly, but I see what the problem is. You use a "cls" at the top of the program, and not when you want to really clear the screen. This means that the first thing you do when the program starts, is to clear the screen, but, however, when you really wan to clear it, it doesn't. And the reason is that you do not tell it to clear the screen then. So all you have to do is to move the "cls" command, to where you want to clear the screen. This should do the trick:



Alternatly you can replace the "cls" at the top of the program with "backdrop on", which init the 3d engine. Then you won't need a "cls".
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 5th Feb 2007 10:53
OK thanks. I realy do appreciate you at least looking at this mess. I will try that. I'm still up at 3:50 am. USA time. I seem to have some other problems as well - with clicking on the play and help buttons. so . . .

Everybody please ignore this thread for the moment!

As opposed to Highlander.
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 5th Feb 2007 16:52
@ Mr. X

I continually want to code DBP as if it were VB. I just can't do that. So what I decided to do after a couple of hours of sleep was to continue coding this in accordance with a gaming engine in mind. This is totally different for me.

So, instead of putting the title page code in the beginning as I was trying to do I made it into a function. So my outline is this:

defined constants/variables
title()
init_game()
run_game()

FYI:

I coded the title page by starting the title page music and at the same time displaying the title image. Then I delayed putting up the next image in conjunction with the rhythm of the music and again delayed putting up the button images. When the button images were displayed I then showed the mouse. At this time the user can then choose either to play or to look at the help screen.




BTW, I do have it working pretty much the way I wanted to. I just shouldn't have stayed up so late.

As opposed to Highlander.
Kieran
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location: Hamilton, New Zealand
Posted: 6th Feb 2007 02:47
thats a good template there f l a t l a n d e r, i made one like that myself



i find this the easiest way to keep everything tidy.

~Kieran
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 6th Feb 2007 10:02
Thanks Kieran. I've only been at this for 3 or 4 weeks; but I'm faithfully going thru a book called DarkBASIC Pro, Game Programming, 2nd Ed. From my main loop (the run_game() loop) I keep track of the game state and also have other functions I use that are similiar to the ones you have indicated in your code snippet.

My advise to newb's like myself is to read the tutorials and get either the above mentioned book or the hands-on volumes through TGC. Hey, I know that everybody is in a hurry to get to the end, but I'm 56 years old and I can be patient -- even though I might keel over any day now.

So, let the games begin.

My first hands-on learning project was based on a popular breakout 2D game. Anyway, if anybody is interested, you can download the files using the links below. This is the project I was getting a little frustrated with as far as that simple clear screen issue.

Exe file - 6.75 MB

Zip file - 2.6 MB

Neither one is an install file. Runs right out of the box. Just put it anywhere on your computer, even the desktop and play.

So, enjoy and let me know if there are any problems or any suggestions.

I still need to finish the top ten list. One of the things that puzzles me is how to determine the difficulty level since I am not actually an experienced gamer. Except for the top ten list and maybe some tweaks here and there I won't be spending much time on this as I want to continue on with my learning. I'm half-way through the book and of course I am excited about getting to the 3D stuff. I also want to experiment with a platform scrolling type game.

As opposed to Highlander.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 6th Feb 2007 16:32
Quote: "but I'm 56 years old and I can be patient"


Forum rules say you shouldn't advertise your age!! Lol

Though I guess that we are both in an age group that wasn't exactly in mind when that rule was thought up so it's not that important!

Quote: "I still need to finish the top ten list."


If you are stuck on this, I cover how to do it in part 4 of my series of tutorials for beginners (on File Access). This can be found here:

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

Quote: "One of the things that puzzles me is how to determine the difficulty level"


Essentially, to increase the difficulty in a Breakout game, you simply speed the ball up a bit and reduce the size and speed of the player's paddle.

This can be done based on the player's current score. Using variables for the width of the paddle and the speed of anything moving (rather than moving it a fixed amount on screen), you can increase/decrease the value of the respective variable.

For example, every 10,000 points you could decrease the paddle width varaible by 1 pixel and increase the speed of the ball.

TDK_Man

Kieran
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location: Hamilton, New Zealand
Posted: 7th Feb 2007 05:54
np f l a t l a n d e r, i managed without the books, i didn't seem to find some snippets ive seen from it that useful so im keeping my hands off dbpro volume 1&2 lol but tutorials are good to follow! and never use GOTO, i found that out the hard way lol had to re-write my program because all the gotos made it to hard to read

~Kieran

Login to post a reply

Server time is: 2024-11-26 00:33:14
Your offset time is: 2024-11-26 00:33:14