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 / Question about printing text.

Author
Message
Dante Corwyn
21
Years of Service
User Offline
Joined: 18th Mar 2003
Location:
Posted: 6th Jun 2006 01:07
I've been fiddeling with this for a while and am getting stuck. I've created a backdrop and an arrow sprite and can easily move the arrow around my screen. I can't however print on the screen the x and y coordinates of the arrow (I set it up so I could see that before I typed in the code for the arrow). It's now one or the other with my code; I'd ideally like both so I can print other bits of text into a game (score, lives, etc). I thought Set Text Transparent might work but no such luck. This is probably a very simple question but it's getting frustrating. I've enclosed my code here. Cheers.
Dante Corwyn
21
Years of Service
User Offline
Joined: 18th Mar 2003
Location:
Posted: 6th Jun 2006 09:08
Thought this would post with my original messages. Here's it again hopefully.
Dante Corwyn
21
Years of Service
User Offline
Joined: 18th Mar 2003
Location:
Posted: 6th Jun 2006 19:36
Thought this would post with my original messages. Here\'s it again hopefully.


REM Setup Variables and everything up
playerx = 150
playery = 150
sync on
sync rate 30
white = rgb(255,255,255)
black = rgb(0,0,0)
speed = 8

Rem start Get Sprites. Taking this part out allows the playerx and playery variables to be printed
load bitmap \"background.bmp\", 0
Rem arrowbmp is just an 8 by 8 sprite
load bitmap \"arrowbmp.bmp\", 1
get image 1,0,0,8,8
sprite 1,170,90,1
rem end
REM Print variables on the screen, change variables, and loop it
do
remstart This part was lifted from page 373 of Beginners guide to DarkBasic
ink 0,0
box 0,200,639,479
ink white,black
remend

if rightkey() =1 then playerx = playerx +speed
if playerx > 640 then playerx = 0
if leftkey() =1 then playerx = playerx -speed
if playerx < 0 then playerx = 639
if upkey() =1 then playery = playery -speed
if playery > 480 then playery = 01
if downkey() =1 then playery = playery +speed
if playery < 0 then playery = 479
x$ =str$(playerx)
y$ =str$(playery)
text 10,10, x$
text 10,22, y$
sprite 1, playerx, playery, 1
sync
loop[/code][code][/code][code]
X Trade
20
Years of Service
User Offline
Joined: 19th Feb 2004
Location: near bristol, UK
Posted: 8th Jun 2006 22:19 Edited at: 8th Jun 2006 22:22
if you notice, when posting. there is a button called 'code'
press that, then type in your code.. (you will see it puts a little tag in square brackets, write your code after the tag. then press the code button again and it should write another tag saying /code in square brackets.

then you get something nice like this:
(click the button to see the code). much tidier




on to your problem:
is this Dark Basic Pro or Dark Basic?
if it is DBP, you need to set the current bitmap back to zero. you can do this by typing the command 'set current bitmap 0'. otherwise it is just outputting your text to the bitmap you loaded earlier.

also, you don't have to get the bitmap for your sprite, you can use the 'load image' command directly to open the .bmp file.

like so:


just because the file FORMAT is a bitmap, you don't need to use the 'load bitmap' command. bitmaps are different to images in that bitmaps are for editing and backgrounds and other stuff, whilst images are for sprites and texturing. the command 'load image' will load .bmp files as well as .jpg, .png, .tga (I think) and many others


also, you don't need those slashes in there, im supprised your code works at all with that!
it should be:
load image "arrowbmp.bmp", 1

NOT:
load image /"arrowbmp.bmp/", 1

www.AoFP.co.uk
Dante Corwyn
21
Years of Service
User Offline
Joined: 18th Mar 2003
Location:
Posted: 11th Jun 2006 15:05
Cheers. It's cleared up a few of the problems I had with the code. I thought I was using the code key okay, but as I'm new to the forum I'm on that admin-checking my text thing. Hopefully I'll get that code key nailed down next time. With the \'s in my code, they're not actually in my code. It must be how the forum set it up. I cut-and-pasted from DarkEdit. No idea why it does that.

I'm using original DarkBasic by the way.

Login to post a reply

Server time is: 2024-11-26 18:28:35
Your offset time is: 2024-11-26 18:28:35