I noticed that as I changed the structure. My player acts all weird now. Ill upload everything I got. The player will continuously fall through the floor, appearing at the top again, and the blocks will "invisibly" move to the left 16 pixels. If I go to far right, ill end up at the left again. If I make a "kill" coordinate, and the player reaches their, instead of the process being killed, it just hangs there. Play the game and you will see what I mean.
EDIT:
I noticed when in structure if playerx becomes int instead of byte i dont jump around left and right. But still I have problem with kill coordinate.
EDIT #2:
Derp moment, forgot I split the player into two process lol.
A byte cannot be a negative value. It is a so called "unsigned" data type, just like the WORD type. A byte ranges from 0-255, and a word from 0-65535). When you use a counter with negative value's it will freak. If you want counters with only 8 bits, you can use signed bytes (-128 to +127). That may be the cause of the strange behaviour.
yeah lol. is a byte good for values as long as their under 255 and are not negative?
that's right. But it saves memory. A byte is only 8 bits (hench 0-255). A word and short int are 2 bytes (16 bits) in size, and a standard integer is 4 bytes (32 bits). If you want negative numbers and conserve memory you can use the "signed" byte, wich ranges from -128 to +127. In general when you go beyond the range of a datatype you get an overflow. http://en.wikipedia.org/wiki/Arithmetic_overflow (http://en.wikipedia.org/wiki/Arithmetic_overflow) and http://en.wikipedia.org/wiki/Integer_overflow (http://en.wikipedia.org/wiki/Integer_overflow).
im using 16bit FPG's, if my game uses only FPG's, should I make them 8bit and change the game to 8bit?
No, no, no! That has nothing to do with data types in this case. In fact you can use 8 bit and 16 bit fpgs in 32 bit mode too.
oh lol. well at the moment everything is working good so far. I got ladders and "monkey bars" to work.
so:
int for variablers over 255 and byte for every other variable?
Quote from: DoctorN on March 13, 2012, 05:42:17 PM
oh lol. well at the moment everything is working good so far. I got ladders and "monkey bars" to work.
so:
int for variablers over 255 and byte for every other variable?
Yeah pretty much. You just have to ask yourself the question: Will this counter ever have to deal with negative numbers, and can I reasonly expect that the numbers are going to be bigger then a certain range. I use the "byte" a lot for situations that I know that the value's will stay within this confined range.
But I have made these mistakes too, and still make them sometimes, just when I forget in my program logic that it's a byte but have forgotten about it and trying to test for something smaller then 0 :-[ (you know programming and beer are not always a sane combination). These are the moments where I want to pull out my hair! ;D Then when I realised the stupid mistake I have a good laugh. :) Any programmer goes through these things.