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! / sprite position problem in dbpro

Author
Message
Lunar Fusion
19
Years of Service
User Offline
Joined: 11th Feb 2007
Location:
Posted: 22nd Feb 2007 22:15
I'm having trouble getting sprites to position correctly...

my code looks like this, I'm just playing around and learning the language....

[/code]

resolutionx = 1024 : resolutiony = 768
set display mode resolutionx, resolutiony, 16
hide mouse
forground = rgb(255,255,255)
background = rgb(0,0,0)
shipx = 500
shipy = 700
backdrop off
sync off
ink forground,background

MakeABackground(shipx, shipy)
loadPlayerShip()

looptime = 0

do
cls 0
inc looptime

paste image 1,0,0
print " loop number: ",looptime
print " res-x: ", resolutionx/2
print " res-y: ", resolutiony-75
print " mouse-x: ", mousex()
print " mouse-y: ", mousey()
moveship()
set cursor 500,500
print "test ", looptime
circle resolutionx/2,resolutiony-75, 100
sprite 2, res-x, res-y,2
sync
loop
end


Function MakeABackground(x,y)
rem background from darkmatter use any
load image "skybox starry.png",1
paste image 1,0,0
endfunction

function loadPlayerShip
rem generic ship, 50x50 pixel
load image "player ship 1.bmp",2
sprite 1, resolutionx/2, resolutiony-75, 2
offset sprite 1, 25,25
set sprite 1,0,1
`second ship

endfunction

function moveship()
sprite 1,mousex(),mousey(),2
print "test2"
endfunction

[code]

I know its messy but I"m just trying to learn concept before I actually start writing hardcore. I bumped into a thread that talked about offsetting the view angle by 80% or something, though I've been lookin for over an hour now and I can't find any information on this type of problem in the forum. Any help is appreciated, thank you : )
old rinkly
22
Years of Service
User Offline
Joined: 11th Mar 2004
Location: Devon UK
Posted: 25th Feb 2007 23:53
Don't know if it helps, but I always use
sprite number,mousex(),mousey(),image
set cursor 10,20
print mousex(),mousey()

then you can place your sprite where you want it and read the co-ords top left of your screen.

old rinkly
Scraggle
Moderator
22
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 26th Feb 2007 09:39
There are many errors in your code.

This line

would produce a 'Division by Zero' error because resolutionx & y are not global and have not been passed to the function.

However, the code can't get that far because you are missing () from the end of the function declaration for loading the ship.

When it comes to position the ship, you are using this code:

Which translates as


Because there are no variables called res, x or y "res-x" & "res-y" are just things that you have printed to screen.



Lunar Fusion
19
Years of Service
User Offline
Joined: 11th Feb 2007
Location:
Posted: 26th Feb 2007 16:24
Thank you soooo much, I forgot about the whole no-global in dbpro (I've in school for computer science and writing in a lot of c++). That now makes much more sense, thank you.

Login to post a reply

Server time is: 2026-07-05 01:11:08
Your offset time is: 2026-07-05 01:11:08