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.

2D All the way! / About Lives

Author
Message
Nobody 1307
16
Years of Service
User Offline
Joined: 9th Mar 2008
Location:
Posted: 9th Mar 2008 20:46
I am new to the use of DarkBasic But I have no clue how I would implement lives into a game.... Is there any easy explanation someone could give me? like an example game or code snippet as an example?
Insert Name Here
17
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 9th Mar 2008 21:37
Have a variable lives, which decreases every time the player loses a life. You can then check to see if lives=0, and that leads to game over.

Lee Bamber - Blame Beer
Venge
17
Years of Service
User Offline
Joined: 13th Sep 2006
Location: Iowa
Posted: 10th Mar 2008 01:55
You mean like little sprite images on the screen showing how many lives you have left?

There are over 100 billion galaxies in our observable universe, each containing up to a trillion stars.

Feeling small yet?
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Mar 2008 12:18
I'd tend to use a set range of sprites, say your lives variable is called LIVES, and you have a little 16x16 heart image loaded as image 100

For n=1 to 10
if n<lives
sprite n+50,100,n*16,0
else
if sprite exist(n+50)
delete sprite n+50
endif
endif
next n

That would step through 9 sprites from 51 to 60, and create or delete them depending on how many lives you have left. I'd do this in a function that I call every time the game starts or a life is lost. I'd use a similar system for score as well, like having the digits as images then convert the score to text and check each element, creating the sprites as I go.


less is more, but if less is more how you keeping score?

Login to post a reply

Server time is: 2024-05-06 17:12:48
Your offset time is: 2024-05-06 17:12:48