Author |
Topic: Finding Tint value for a Sprite (Read 388 times) |
|
Danny
New Member
member is offline


Posts: 12
|
 |
Finding Tint value for a Sprite
« Thread started on: Jan 27th, 2016, 9:24pm » |
|
Hi
Am having difficulty getting a value using TINT when there is a sprite.
I have a red coloured Sprite but when using Tint it gives me a zero value.
I hope someone could let me know if this is possible.
Many thanks in anticipation,
Danny
|
|
Logged
|
|
|
|
DDRM
Administrator
member is offline


Gender: 
Posts: 321
|
 |
Re: Finding Tint value for a Sprite
« Reply #1 on: Jan 28th, 2016, 3:27pm » |
|
Hi Danny,
I claim no expertise, but you aren't getting any other help, so...
I think the problem is that the sprite(s) are not part of the main display bitmap, and I suspect TINT is pulling the info from the main bitmap rather than the sprite. You could try that out by drawing something (say a green rectangle) on the main window, flying your sprite over it, and seeing if TINT returns green!
Ooh, I just went and had a look at spritelib, and it might be even worse than that. I think it makes a duplicate "main bitmap" - I'm guessing it keeps one as a reference and draws on the other one, so I'm not sure which TINT will look at.
As an aside, do you mean to use TINT (which will return an RGB colour) rather than POINT (which will return the palette index). If you are trying to sample a sprite, you may well do!
Good luck...
D
|
|
Logged
|
|
|
|
Danny
New Member
member is offline


Posts: 12
|
 |
Re: Finding Tint value for a Sprite
« Reply #2 on: Jan 28th, 2016, 4:37pm » |
|
Hi D
Thanks for the reply. Yes, I can get both Point and Tint to see the rectangle behind my red sprite. But as yet, am unable to get anything for the sprite itself.
The thing that I'm looking to achieve is in a football game, to see if the sprite football, when it is moving through the green pitch (am using the rectangle) if the ball encounters a sprite defender player (in red).
I guess this is normally known as a collision. I don't know what *sampling* a sprite means, so will look that up.
|
|
Logged
|
|
|
|
DDRM
Administrator
member is offline


Gender: 
Posts: 321
|
 |
Re: Finding Tint value for a Sprite
« Reply #3 on: Jan 29th, 2016, 08:23am » |
|
Hi Danny,
I presume that, behind the scenes, when you ask for a TINT value of a point BB4W goes and looks at the contents of the memory location in the screen bitmap corresponding to your point - that's what I mean by sampling. My guess is that TINT will test the main screen bitmap, which won't include data from the sprites.
Your simplest solution might simply be to calculate the distance from the (centre of) the ball to the (centre of?) the player(s), and then work out whether that is less than the radius of the ball plus the width/height of the player(s). That's computationally a bit more expensive that looking at the screen, but given that there aren't going to be that many players, it may not actually be slower, since typically interacting with the graphics system is quite slow (relatively!).
There are some slightly fancier tricks that might speed things up - for example, if you kept the player x coordinates in an array, and took away the ball's x coordinate from the whole array, then you could skim through, and only check more closely if the remaining distance in the x direction was such that contact with a given player was possible.
Hope that's useful.
D
|
|
Logged
|
|
|
|
Danny
New Member
member is offline


Posts: 12
|
 |
Re: Finding Tint value for a Sprite
« Reply #4 on: Jan 29th, 2016, 10:03am » |
|
Hiya D
Thanks for the tips. Yes, I will try some of these coordinate methods of finding collisions. it will probably make for a better game simulation. EA sports (Fifa game) will be worried 
Danny
|
|
Logged
|
|
|
|
|