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 / Flakey looking sprite

Author
Message
jerryd
11
Years of Service
User Offline
Joined: 20th Feb 2013
Location:
Posted: 25th Feb 2013 07:18
DarkBasic forum,

Still pretty new at this but I have a program that shoots a
basketball at a basket with all the appropiate trig and physics.
The sync is on, the sync rate is set to 30 and backdrop is on.

Advancing the time at 0.1 increments gives the ball about the
right ralative speed but it's not always solid looking on the
screen. Sometimes simi-transparent. What can I do to make it
look better?

Jerryd
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 25th Feb 2013 13:21
Could you perhaps upload the image you're using for the ball so I can examine it?

There's not enough information to draw a solid conclusion, so here are some ideas:

-Does the image have an alpha channel and is it being used?
-Are there sprites that are on top of the ball?
-Are you doing something odd with the sprite's diffuse alpha channel?

TheComet

http://blankflankstudios.tumblr.com/
"You're all wrong. You're all idiots." - Fluffy Rabbit
"Bottom line, people are retarded." - Fluffy Rabbit
jerryd
11
Years of Service
User Offline
Joined: 20th Feb 2013
Location:
Posted: 26th Feb 2013 01:50
TheComet,
Thanks for the reply.

I haven't addressed the alpha channel for this sprite.
There are only 2 sprites on the screen, the basketball
and the basket not even a background. All that happens
is the ball is launched toward the basket. The ball is
just a 2D sprite. I've attached the .PNG file.

I think the semi-transparency is because the sprite
doesn't stay in one place long enough to be totally
perceived by eye.

Jerryd

Attachments

Login to view attachments
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Feb 2013 11:03
Nothing is wrong with the image. Can you post your code?

"You're all wrong. You're all idiots." ~Fluffy Rabbit
jerryd
11
Years of Service
User Offline
Joined: 20th Feb 2013
Location:
Posted: 27th Feb 2013 03:23
DarkBasic forum,

Here's the function that shoots the ball.
I don't know how to do a "code snippet"

`this function shoots the ball
function shoot()

`set the starting position of the ball
xpos = xstart : ypos = ystart

`start the time to 0
time = 0.0

`this do/loop moves the basketball until it hits the basket
`or goes off the screen
do
`calculate the new location of the ball
new_xpos = v0 * time * cos(algle)
new_ypos = v0 * time * sin(angle) - (0.5 * gravity *(time^2))

`update the x,y variables for the ball
xpos = xstart + new_xpos
ypos = ystart - new_ypos

`check if the ball is going to go off the screen
if xpos > screen width() then exit
if xpos <0 then exit
if ypos > screen height() then exit
if ypos <0 then exit

`put the ball at the new position in screen memory
sprite 1, xpos, ypos, 1

`update the screen to show the ball at the new position
sync

`check if the ball hit the basket
if sprite hit(1,2)=1 then exit

`advance the time
time = time + 0.3
loop

'put the ball back at the starting position
sprite 1, xstart, ystart, 1

`update the screen
sync

endfunction

Jerryd
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Feb 2013 17:42 Edited at: 27th Feb 2013 17:43
I wouldn't put a loop inside a function like that.

Did you call sync on?

This:
xpos = xstart : ypos = ystart

Is meaningless, unless those variables were set global outside the function. In which case, bad practice, pass the values to the function as parameters. Even so, you're overwriting xpos/ypos just below it anyway so it's still pointless.

You also have a typo where you spelled 'angle' wrong, resulting in 0 being passed to the equation instead. That could cause issues.

Also, to make a code snippet, just click the code button twice to make the starting and ending tags and wrap your code inside it.

[ code ] insert code here [ /code ]





"You're all wrong. You're all idiots." ~Fluffy Rabbit

Login to post a reply

Server time is: 2024-11-23 14:52:10
Your offset time is: 2024-11-23 14:52:10