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 / Hp not printing

Author
Message
Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 19th Jan 2008 18:52
I need some help my hp isn't printing on screen heres the code


Windows Is better than everything
Sinani201
18
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 19th Jan 2008 18:54 Edited at: 19th Jan 2008 18:55
? I don't get it. What kind of HP are you talking about?
The code works fine on my computer, until you load the image that I don't have on my computer.

Seriously, how do you make the little blue text come up below your message?
Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 19th Jan 2008 18:56
if you look above it says hp = 500 and if you look in the loop it says print hp but the hp health points aren't showing on the screen.

Windows Is better than everything
Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 19th Jan 2008 18:58
i'll up load the image and source code on this post it's an rar unless you want a sfx file

Windows Is better than everything

Attachments

Login to view attachments
Sinani201
18
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 19th Jan 2008 20:53 Edited at: 19th Jan 2008 20:55
never use the print command in a loop! Use the Text command. I'll post the code.



Seriously, how do you make the little blue text come up below your message?
Link102
20
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 19th Jan 2008 21:06
there's nothing wrong with the print command in a loop.
I always check my variables with
set cursor 0,0
print "yada yada"

Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 19th Jan 2008 21:27
both of you codes don't work it still won't display.

Windows Is better than everything
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th Jan 2008 21:43
Sinani201 is correct - Text is better in a loop than Print and Link102 is right saying that Print is OK - providing you use Set Cursor as well.

Print in a loop will print down the screen, but doesn't scroll automatically so without a CLS you won't see all of the output.

I suggest you use:

Sync
Ink RGB(255,255,255),0: Text 0,0,Str$(Hp)


But be sure to add it after the Sync at the end of the main program loop.

Quick Tip: Sort your indentation out! Done properly it will save you loads of time in the future and we'll be more inclined to help you with your problems if we can read your code easier.

TDK_Man

Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 20th Jan 2008 00:49
@ Tdk
I tried what you said it didn't work.

Windows Is better than everything
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 20th Jan 2008 02:09 Edited at: 20th Jan 2008 02:09
Also if you can work out where the problem is coming from post that block of code instead of the whole program

I've taken a look at your code and your hp variable prints fine, it prints so well it goes right off the bottom of the screen but then others have already explained what to do about that

I've played around with your controls a bit to condense your code; you were checking for the same thing over and over which usually means you can do it a better way.

I will explain what I've done, maybe some of the ideas will be useful to you in the future.

Firstly I made two variables to store the leftkey() and rightkey()
l=leftkey() : r=rightkey()
I like to store inputs in variables for two reasons:
A. It's quicker to type.
B. They are stable for the entire loop or until you look at the inputs again.
Being able to think about inputs as just another set of numbers will help you to use maths to great effect in your programs.

The most significant modification I made was putting both left and right movement into the same block. At first it doesn't look like you can do this because they do the opposite, but if we use the left and right variables themselves we can condense it all into the same block of code. The movement code is a good example of this
spritex=spritex+(r*2)-(l*2) : `move horizontally
If rightkey is pressed then r=1 and 1*2 is 2, so by adding 2 to the sprite position we are moving it right, and it's exactly the same for left except we are subtracting the result.

In order to mirror the sprite so that it's facing the correct way, we again need to think of our inputs as numbers.
I haven't seen your image but I'm going to assume that link is facing right; so if we are moving right we don't want our sprite to be mirrored (sprite mirrored(1)=0 is want we want). So obviously if we are moving left we want our sprite to be mirrored so it faces left (sprite mirrored(1)=1).
A simple way to do this would be:
if r=1 and sprite mirrored(1)=1 then mirror sprite 1
if l=1 and sprite mirrored(1)=0 then mirror sprite 1

but we have this opposite thing again between left and right.
r seems to be the most important of the two here: when r=1 if sprite mirrored()=1 (the same as r) we need to mirror the sprite, also (assuming that when l=1 r=0) if r=0 and sprite mirrored()=0 (same as r) we need to mirror the sprite.
So we can make a simple equation based on r:
if sprite mirrored(1) = r then mirror sprite 1 : `mirror
I think I've explained that in a very complicated way but hopefully the equation makes sense.

The final thing I did was add in the reset animation line into the block. This is what ELSE is for:

if l+r = 1 :`if either leftkey or rightkey is pressed (not both)
`true code here
else
framenumber = 1 :`reset animation
endif


I hope that was of use to you

Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 20th Jan 2008 20:41
this is driving me crazy i've tried doing the text metiod and print metiod heres what i have right now at the end still no luck


Windows Is better than everything
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 21st Jan 2008 01:12 Edited at: 21st Jan 2008 01:17
When the program is running, hit the Esc key.

At the bottom of the screen type:

Ink RGB(255,255,255),0
CLS
Print Hp


What appears on the screen?

[Edit] Actually I just noticed something. Do you know what Load Bitmap does?

As you don't seem to have a Set Current Bitmap 0 line in there, probably not.

So my guess is that after doing the above, you'll still have a blank screen.

TDK_Man

Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 21st Jan 2008 23:37
yep you guessed it blank screen but when i mean blank screen you know i mean that i can see my sprites and make them move all i'm saying is that the hp isn't showing and for the sprite i'm using this code
To use this code first i paste this code in dark basic



next i run it and press print screen to copy the boxes then i use the get image from box code to get the image.

Windows Is better than everything
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 21st Jan 2008 23:45
OK, sprites are a case of their own, so this is a red herring.

In DB there are 32 bitmaps (screens) in total. Numbers 1 to 31 are never seen - they are hidden.

Screen 0 (zero) is the one that you see on your monitor.

Loading or creating a bitmap automatically switches all output to the relevant bitmap (with the exception of sprites which can only appear on screen 0).

As stated above, you did not use Set Current Bitmap 0 - even though you used 'load bitmap "linksprite.bmp" ,1' - which would have directed DB to send everything from that moment on to hidden screen 1.

This means that ALL 2D commands, Print and Text commands will still all be outputting to bitmap 1 - and you cannot see it!

TDK_Man

TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 22nd Jan 2008 14:15
Try putting this at the start of the code:



TheComet

Oooooops!!! I accidentally formated drive c.
Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 22nd Jan 2008 15:58
I have this problem with my HP printer too. Try plugging it in.

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 22nd Jan 2008 22:00
@ben
haha

Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 22nd Jan 2008 23:59
yes putting bit map to 0 soved the problem but just one thing has come up when thr program starts up you can see the wlohe bit map for a sec say 1 sec anyway to get rid of this?

Windows Is better than everything
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 23rd Jan 2008 02:06
set sync on before loading the bitmap and only place a sync in the main loop.
If that still doesn't work set gamma 0,0,0 at the start and then set gamma 255,255,255 after everything's set up.
Look up SET GAMMA in the help file

Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 23rd Jan 2008 03:44
thanks

Windows Is better than everything

Login to post a reply

Server time is: 2025-06-02 09:59:13
Your offset time is: 2025-06-02 09:59:13