BBC BASIC for Windows
« Finding Tint value for a Sprite »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:01pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Finding Tint value for a Sprite  (Read 388 times)
Danny
New Member
Image


member is offline

Avatar




PM


Posts: 12
xx 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
User IP Logged

DDRM
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 321
xx 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
User IP Logged

Danny
New Member
Image


member is offline

Avatar




PM


Posts: 12
xx 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.
User IP Logged

DDRM
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 321
xx 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
User IP Logged

Danny
New Member
Image


member is offline

Avatar




PM


Posts: 12
xx 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 wink

Danny
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls