changing luminosity by rgb values.(my tetris game project)

The Partridge Family were neither partridges nor a family. Discuss.
User avatar
viruskiller
Posts: 399
Joined: June 14th, 2012, 5:07 pm

Re: changing luminosity by rgb values.(my tetris game proje

Post by viruskiller » July 1st, 2012, 9:27 am

not sure if that's the stack end or whatever,it seems that just declaring an int array with 7 members it's enough to mess with the game,not sure what is happening,but i think is the compiler just clearing unused intergers after every function in the game has been called or every path has been cheked,that's when a shape hits the bottom,new shape is generated and update blocks is called.

so if it's like that.. well it looks like some ppl were right stating c++ has retarded compilers.
or i may be retarded,i'm just wondering if is posible to change some settings so that the compiler doesn't do stuff behind our backs and sets us on searching bugs that are not there or whatever.

i know that for experienced programers stuff like this is normal,but for a beginner i'm asking my self why the **** it has to be like this? cant the compiler stop trying to babystep us every single time?

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: changing luminosity by rgb values.(my tetris game proje

Post by chili » July 1st, 2012, 10:52 am

I 100% guarantee you virus that the compiler is not to blame. ;)

I will look at your shiz when I have time, but right now I need to record a new lesson.
Chili

User avatar
viruskiller
Posts: 399
Joined: June 14th, 2012, 5:07 pm

Re: changing luminosity by rgb values.(my tetris game proje

Post by viruskiller » July 1st, 2012, 11:20 am

can't wait for the new lesson :D

User avatar
viruskiller
Posts: 399
Joined: June 14th, 2012, 5:07 pm

Re: changing luminosity by rgb values.(my tetris game proje

Post by viruskiller » July 1st, 2012, 2:27 pm

aaaand surprise surprise, i've changed my tetris code to work on just a single square table array,but i get same shiz when i add a new array,and that seems to not happen if i add the new array at the end of my variable list,but whenever i add a new variabile to be close to my square table array in the list it will fuck it up for the first round.
what is the difference between this

Code: Select all

	int SX[180]; 
		int SY[180];
		SQRState s[180];					   
		int retval;                 
		bool KPLastF;                    
		float ShapeSpeed;
		float TempSpd;
		int fc;
		float TempSpdLR;
		float ShapeSpeedLR;
		bool speedbreak;
		bool clearcheck;
		
                int fx[180];
and this

Code: Select all

	int SX[180]; 
		int SY[180];
		SQRState s[180];

   	          int fx[180];
		   
		int retval;                 
		bool KPLastF;                    
		float ShapeSpeed;
		float TempSpd;
		int fc;
		float TempSpdLR;
		float ShapeSpeedLR;
		bool speedbreak;
		bool clearcheck;
			
???

first variable list works just fine,the second one messes up my square array coordinates and show's squares where they should not be,and it all seems fine after first piece hits the bottom.

i'm really confused right now,do we have to keep track of what variables are used first and put them in the list acordingly?
or we just have to initialize all of them before using them?

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: changing luminosity by rgb values.(my tetris game proje

Post by chili » July 1st, 2012, 3:08 pm

That is probably a symptom of a loop somewhere running out of bounds and accessing memory outside of the intended array, thereby messing up your other variables on the stack.
Chili

User avatar
viruskiller
Posts: 399
Joined: June 14th, 2012, 5:07 pm

Re: changing luminosity by rgb values.(my tetris game proje

Post by viruskiller » July 1st, 2012, 4:34 pm

i wish there was something to tell me whenever loops go out of bounds:( it was the update blocks function starting at y=18 value which was 1 line below the table and since that line was empty all time it just shifted the shape to it,now the thing is since that line had a non empty square new shapes were not shifted and that failing the empty line check it would clear just the shapes above.

now the line below the table as u guessed it was outside of the array and that's why it only appeared when i had other array's in same region on the stack.

i always keep forgetting that array's start at 0 and end 1 below max number:(

anyway thanks for pointing me in the right directoon :lol: dunno if i could have found that on my own :roll:

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: changing luminosity by rgb values.(my tetris game proje

Post by chili » July 2nd, 2012, 2:27 pm

Later we'll be making use of std::vector. It does let you know when you're exceeding the bounds. Google it if you're interested and wanna get a leg up on the tutorials.
Chili

User avatar
viruskiller
Posts: 399
Joined: June 14th, 2012, 5:07 pm

Re: changing luminosity by rgb values.(my tetris game proje

Post by viruskiller » July 2nd, 2012, 5:18 pm

i've read a bit on C++ reference,altough is ahrd for me to understand what goes where and what means what:/
i mean i'm not sure what are user defined names and what are standard names,i wish they listed they'r therms with a better explanation:(

for example what does explicit mean,is the name of the vector i should give?

explicit vector ( const Allocator& = Allocator() );
explicit vector ( size_type n, const T& value= T(), const Allocator& = Allocator() );
template <class InputIterator>
vector ( InputIterator first, InputIterator last, const Allocator& = Allocator() );
vector ( const vector<T,Allocator>& x );
Construct vector
Constructs a vector container object, initializing its contents depending on the constructor version used:

explicit vector ( const Allocator& = Allocator() );
Default constructor: constructs an empty vector, with no content and a size of zero.
explicit vector ( size_type n, const T& value= T(), const Allocator& = Allocator() );
Repetitive sequence constructor: Initializes the vector with its content set to a repetition, n times, of copies of value.
template <class InputIterator> vector ( InputIterator first, InputIterator last, const Allocator& = Allocator() );
Iteration constructor: Iterates between first and last, setting a copy of each of the sequence of elements as the content of the container.
vector ( const vector<T,Allocator>& x );
Copy constructor: The vector is initialized to have the same contents (copies) and properties as vector x.

what is const alocator& = alocator();?

if i look at the examples i may be able to replicate it and maybe change something but is hard to understand every parameter name ,altough i've got a general idea of how this thing works ,and i can see a number of advantages for using it:)
anyway i'm going to wait for the tutorial for now:D

User avatar
viruskiller
Posts: 399
Joined: June 14th, 2012, 5:07 pm

Re: changing luminosity by rgb values.(my tetris game proje

Post by viruskiller » July 8th, 2012, 3:07 pm

i've worked more on my tetirs game :D
now it has load score,save score,load game and save game functions,
also mapped 3 more key's to trigger load and save game functions since i use enter for reset game and all arrow key's for playing .
was quite a challange to mapp new key's.first i touht i had to just add them in keyboard .h,then i realized there was something else that was changing the bool key state variables.
and found it to be in windows.h,but there again didn't knew where were those key defined ,and found it in winuser.h ,
and after long reading there found it i just have to pass the hex value of the ascii code for that key instead of VK_L or what key i wanted to map, and then it all worked fine :lol:

here's the file
tetris 1.1.zip
(53.03 KiB) Downloaded 327 times
ps:forgot to mention the key;s for saving and loading :)
ther's S for saving and L for loading
Last edited by viruskiller on July 8th, 2012, 4:10 pm, edited 1 time in total.

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: changing luminosity by rgb values.(my tetris game proje

Post by chili » July 8th, 2012, 3:27 pm

Good job figuring out how the keyboard code works. ;)
Chili

Post Reply