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 / Can you delete text?

Author
Message
MoNkEyMaN
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: United Kingdom
Posted: 6th Feb 2003 18:35
Is there a command that can delete text that has been written to the screen?
I am adding a scoring system to my game which will be updated and printed each time the player's score increases.
My first idea was to just re-print it normally each time, but that did not work because the score was printed ontop of the last score and it became a jumbled mess.

Please help me with this!
MnKMaN
Hamish McHaggis
21
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 6th Feb 2003 18:49
use the cls command to clear the screen each time
use sync then cls for smooth transitions.

Yum! Yum! Yum! Yum!
MoNkEyMaN
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: United Kingdom
Posted: 6th Feb 2003 19:43
How do you make it smoother?
At the moment it is very jumpy 8(

Hide Mouse
Sync On
Sync Rate 60

Load Music "Hidden Fury.mid",1
Loop Music 1



Repeat
repeat
Set Text Size 50
Center Text 320,20, "PONG!"
Set Text Size 10
Center Text 320,300, "Type 1 and press enter for One Player!"
Center Text 320,315, "Type 2 and press enter for Two Player!"
Center Text 320,450, "Press Space to exit"
Set Cursor 320,240

sync


choice$=inkey$()
until choice$="1" or choice$="2" or choice$=" "

cls

If choice$ = "1" then Gosub OnePlayer
If choice$ = "2" then Gosub TwoPlayer

Until choice$ = " "
end

InitialiseForPlay:
radius# = 3.0
score = 0
secondscore = 0
secondpspeed = 10
ballxpos = 320
ballypos = 240
ballyspeed = Rnd(4)
ballxspeed = 12

` Also initialise the second player - doesn't matter if its not needed
secondxpos = 530
secondypos = 240

return

Oneplayer:
gosub InitialiseForPlay
Do

Set Text Size 50
Center Text 320,20, "PONG!"
Set Text Size 10

Line 98,98,542,98
Line 542,98,542,382
Line 542,382,98,382
Line 98,382,98,98

Create bitmap 1,25,25

Line 1,1,1,21

Get Image 1,1,1,2,22

Set Current Bitmap 0

Sprite 1,xpos,ypos,1

ypos = MouseY()
xpos = 110

If ypos < 100 then ypos = 100
If ypos > 360 then ypos = 360

Create Bitmap 2,25,25

Circle 5,5,radius#

Get Image 2,1,1,10,10

Set Current Bitmap 0

Sprite 2,ballxpos,ballypos,2

ballxpos = ballxpos - ballxspeed
ballypos = ballypos + ballyspeed


If ballxpos > 534 then ballxspeed = ballxspeed * -1
If ballxpos < 100
ballxspeed = ballxspeed * -1
Endif

If ballypos < 97 then ballyspeed = ballyspeed * -1
If ballypos > 374 then ballyspeed = ballyspeed * -1

if ballxpos < xpos + 6 and ballxpos > xpos - 20 and ballypos < ypos + 20 and ballypos > ypos - 20
ballxspeed = ballxspeed * -1
score = score + 1
Endif

Rem PRINT SCORE TO SCREEN
Rem PRINT SCORE TO SCREEN
Sync
Cls
Text 0,0,"Score:"+str$(score)




If score >= 50
Cls
Delete Sprite 1
Delete Sprite 2
center text 320,240,"You win with "+str$(score)+" points!"
Wait 2000
Cls
`Gosub MainMenu
return
Endif


If Spacekey()=1 then End
Center Text 320,450, "Press Space to Exit"
Center Text 320,390, "You need 50 points to win!!"
Center Text 320,435, "Press Shift to go back to Main Menu!"

If Shiftkey()=1
Cls
Delete Sprite 1
Delete Sprite 2
`Gosub MainMenu
return
Endif

Sync
Loop

TwoPlayer:
gosub InitialiseForPlay

Do

Set Text Size 50
Center Text 320,20, "PONG!"
Set Text Size 10

Line 98,98,542,98
Line 542,98,542,382
Line 542,382,98,382
Line 98,382,98,98

Create bitmap 1,25,25

Line 1,1,1,21

Get Image 1,1,1,2,22

Set Current Bitmap 0

Sprite 1,xpos,ypos,1

Sprite 3,secondxpos,secondypos,1

if upkey()=1 then dec secondypos,secondpspeed
if downkey()=1 then inc secondypos,secondpspeed

ypos = MouseY()
xpos = 110

If ypos < 100 then ypos = 100
If ypos > 360 then ypos = 360

If secondypos < 100 then secondypos = 100
If secondypos > 360 then secondypos = 360

Create Bitmap 2,25,25

Circle 5,5,radius#

Get Image 2,1,1,10,10

Set Current Bitmap 0

Sprite 2,ballxpos,ballypos,2

ballxpos = ballxpos - ballxspeed
ballypos = ballypos + ballyspeed

If ballxpos > 534
ballxspeed = ballxspeed * -1
secondlives = secondlives - 1
Endif
If ballxpos < 100
ballxspeed = ballxspeed * -1
lives = lives - 1
Endif
If ballypos < 97 then ballyspeed = ballyspeed * -1
If ballypos > 374 then ballyspeed = ballyspeed * -1

If ballxpos < xpos + 6 and ballxpos > xpos - 20 and ballypos < ypos + 20 and ballypos > ypos - 20
ballxspeed = ballxspeed * -1
score = score + 1
Endif

If ballxpos > secondxpos - 12 and ballxpos < secondxpos + 20 and ballypos > secondypos - 20 and ballypos < secondypos + 20
ballxspeed = ballxspeed * -1
secondscore = secondscore + 1
Endif


If Spacekey()=1 then End
Center Text 320,450, "Press Space to Exit"
Center Text 320,390, "You need 50 points to win!!"
Center Text 320,435, "Press Shift to go back to Main Menu!"
Sync
Cls
Text 0,0,"Score:"+str$(score)
If score >= 50
Cls
Delete Sprite 1
Delete Sprite 2
Delete Sprite 3
center text 320,240,"Player 1 wins with "+str$(score)+" points!"
Wait 2000
Cls
`Gosub MainMenu
return
Endif

Sync
Cls
Text 530,0,"Score:"+str$(secondscore)
If secondscore >= 50
Cls
Delete Sprite 1
Delete Sprite 2
Delete Sprite 3
center text 320,240,"Player 2 wins with "+str$(score)+" points!"
Wait 2000
Cls
`Gosub MainMenu
return
Endif

If Shiftkey()=1
Cls
Delete Sprite 1
Delete Sprite 2
Delete Sprite 3
`Gosub MainMenu
return
Endif

Sync
Loop

MnKMaN
Shadow
22
Years of Service
User Offline
Joined: 17th Oct 2002
Location: In the shadows
Posted: 6th Feb 2003 21:59
You should only have 1 cls and 1 sync per loop.
Also, you should not be handling bitmaps inside the loop. Get the images before the loop starts.
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 7th Feb 2003 00:41
I would recommend storing the text in a string, then just changing the string to be "" and then print the string afterwards.

RPGamer

Current - RPG: Eternal Destiny : Help Wanted!
http://www.halbrosproductions.netfirms.com
Dont ask those questions! Read the help files lazy!

Login to post a reply

Server time is: 2024-11-27 17:13:30
Your offset time is: 2024-11-27 17:13:30