Using pointers for sprites.

Previous topic - Next topic

kanonet

Quote from: siatek on 2012-Nov-29about the floats in modern hardware i think that there is no speed advantage of use integeres ? am i wrong ?  (and we have a lot of memory right ;) )
Why waste memory? And integers are still faster than floats, they are just way easier to calculate. And they are not always fully accurate. And you should avoid variable type conversation at all, cause they are slow too. Many commands require you to input integers (array want integers as index too!), like DRAWSPRITE does too. If you input a float in a function that wants integers, every float variable will get converted from float to integer every single time you call it. - Obviously this is a huge waste of speed. If you are able to, you should always use integers and be sure that you select the right type of variable for you needs and check what your functions need as input.

Btw. you should also prefer LOCAL over GLOBAL. 1st this avoids var name collisions in different parts of you project (keep it encapsulated!) and LOCALs are a tiny bit faster than GLOBALs too.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

fuzzy70

What would be handy is more data types, for example we have commands to read BYTE/UBYTE/WORD/UWORD etc from files but as soon as you read a byte into a integer it jumps from being an 8bit value to a 32bit one.

However, how it could me implemented is another matter & may just cause confusion or problems as we have $/%/# used already so extra symbols would have to be used. I get round it by using AND/OR & ASL/ASR although have no idea what performance loss it takes (might be very small).

With regards to memory mobile devices are (on general) way behind desktop pc's with the amount of available ram, some android devices only having 256mb/512mb & with all the running processes like messaging etc whats left can be pretty small.

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

kanonet

At the moment we have 4 native GLB data types: integer (%), float (#), string ($) and 64-bit integer (called int64, no short symbol), + custom Types.

But you can also use C data types, like:
Code (glbasic) Select
LOCAL a AS char
So you can already save memory in GLB. But keep in mind that you may lose speed if you use them to calc or input in functions with different datatypes, cause you would force type conversations.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Lord_TNK

Quote from: kanonet on 2012-Nov-29
Quote from: siatek on 2012-Nov-29about the floats in modern hardware i think that there is no speed advantage of use integeres ? am i wrong ?  (and we have a lot of memory right ;) )
Why waste memory? And integers are still faster than floats, they are just way easier to calculate. And they are not always fully accurate. And you should avoid variable type conversation at all, cause they are slow too. Many commands require you to input integers (array want integers as index too!), like DRAWSPRITE does too. If you input a float in a function that wants integers, every float variable will get converted from float to integer every single time you call it. - Obviously this is a huge waste of speed. If you are able to, you should always use integers and be sure that you select the right type of variable for you needs and check what your functions need as input.

Btw. you should also prefer LOCAL over GLOBAL. 1st this avoids var name collisions in different parts of you project (keep it encapsulated!) and LOCALs are a tiny bit faster than GLOBALs too.

1. I would keep pointers different anyway, since it wouldn't make sense to give different bitmaps the same names regardless.

2. I think bitmaps that are to be used for most of the game would best be given pointers globally, while sprites in certain situations could be local (such as enemies just for certain areas.