Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
Lapsa's very own thread
by rki. 06/19/24 11:27
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 692 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Mino, squik, AemStones, LucasJoshua, Baklazhan
19061 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Does not do what I except!! #411758
11/19/12 15:34
11/19/12 15:34
Joined: Nov 2011
Posts: 139
India
Yashas Offline OP
Member
Yashas  Offline OP
Member

Joined: Nov 2011
Posts: 139
India
Code:
#include <acknex.h>
//#include "..\\..\\..\\data\\scripts\\game_api.c"
////////////////////////////////////////////////////////////////////////////////////////////////////
BMAP * SpeedRun_Shapes[10];

////////////////////////////////////////////////////////////////////////////////////////////////////

int  SpeedRun_Score;
int  SpeedRun_Time;

int SpeedRun_Running;


void SetTimer (int * p,int time,void * func)
{
	void * temp_func();
	
	while(*p > 0)
	{
		wait((time * -1));
	}	
	if(func) { temp_func = func; temp_func(); }
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEXT * SpeedRun_Text = {layer = 11; font = "Arial#20b"; pos_x = 50; pos_y = 200; alpha = 0; flags = TRANSLUCENT; string = "Remember each new symbol that appears.\nCompare the new symbol with the previous symbol that appeared.\nHit \"Right Arrow\" if they match else the \"Left Arrow\"\nBe Careful Right answers in a row give you more score\nBe Quick You need to score as much as possible in a time given. "; }
PANEL * SpeedRun_GameBackground =
{
	bmap = "background.tga";
	alpha = 0;
	layer = 10;
	
	flags = TRANSLUCENT | OVERLAY;
}
PANEL * SpeedRun_Controls =
{
	alpha = 0;
	layer = 10;

	digits(50,50,"Speed Run","Arial#70b",1,0);
	digits(50,130,"Hit the right key at the right time","Arial#30b",1,0);
	
	
	digits(1000,1000,"Time Remaining:%2.f","Arial#30b",1,SpeedRun_Time);
	digits(3000,100,"Score:%2.f","Arial#30b",1,SpeedRun_Score);
	
	window(2000,150,200,200,"shape1.tga",200,200);
	
	
	digits(230,420,"Play","Arial#50b",1,0);
	button(120,400,"button1.tga","button2.tga","button1.tga",SpeedRun_StartPlay,NULL,NULL);
	flags = TRANSLUCENT | OVERLAY;
}

void SpeedRun_StartPlay ()
{
	int Previous = 0;
	var Time;// = sys_malloc(sizeof(int));
	var Score; //= sys_malloc(sizeof(int));
	BMAP * Temp; 
	int Row;
	int Correct;
	int Wrong;
	int TechPoints;
	int Current;
	
	//pan_setdigits(SpeedRun_Controls,1,20,20,"Speed Run - Speed","Arial#25b",1,sys_seconds);//sys_seconds for DUMMY - For the sake of a pointer var
	
	//pan_setstring(SpeedRun_Controls,1,100,100,"Arial#25",str_create("Speed Run"));
	//pan_setbutton(SpeedRun_ControlsPlaying,1,0,-100,-100,bmap_create("button1.tga"),bmap_create("button1.tga"),bmap_create("button1.tga"),NULL,NULL,NULL,NULL);
	if(SpeedRun_Running)
	{
		Time = 45;
		Current = integer(random(6));
		//Previous = Current;
		Temp = SpeedRun_Shapes[Current];
		pan_setwindow(SpeedRun_Controls,1,200,150,200,200,Temp,200,200);
		pan_setdigits(SpeedRun_Controls,3,50,70,"Time Remaining:%d",font_create("Arial#30b"),1,Time);
		pan_setdigits(SpeedRun_Controls,4,320,70,"Score:%d",font_create("Arial#30b"),1,Score);
		pan_setdigits(SpeedRun_Controls,5,2000,20,"%f",font_create("Arial#40"),1,sys_seconds);
		pan_setbutton(SpeedRun_Controls,1,0,2000,0,Temp,Temp,Temp,NULL,NULL,NULL,NULL);
		
		while(Time != 0)
		{
			Row = 1;
			Score = 0;
			if(key_cur) //SAME
			{
				if(Current == Previous)
				{
					//Correct
					//AddUserXP(2);
					Score += 5 * Row;
					Row++;
					Correct++;
					TechPoints++;
					Previous = Current;
					Current = integer(random(6));
					Temp = SpeedRun_Shapes[Current];
					pan_setwindow(SpeedRun_Controls,1,200,150,200,200,Temp,200,200);	
					while(key_any) { wait(1); }				
				}
				else
				{
					//Wrong
					//AddUserXP(1);
					Row = 1;
					Score += 5 * Row;
					Wrong++;
					TechPoints--;
					Previous = Current;
					Current = integer(random(6));
					Temp = SpeedRun_Shapes[Current];
					pan_setwindow(SpeedRun_Controls,1,200,150,200,200,Temp,200,200);	
					while(key_any) { wait(1); }				
				}
			}
			else if(key_cul) //NOT SAME
			{
				if(Current == Previous)
				{
					//Wrong
					//AddUserXP(1);
					Row = 1;
					Score += 5 * Row;
					Wrong++;
					TechPoints--;
					Previous = Current;
					Current = integer(random(6));
					Temp = SpeedRun_Shapes[Current];
					pan_setwindow(SpeedRun_Controls,1,200,150,200,200,Temp,200,200);
					while(key_any) { wait(1); }
				}
				else
				{
					//Correct
					//AddUserXP(2);
					Score += 5 * Row;
					Row++;
					Correct++;
					TechPoints++;
					Previous = Current;
					Current = integer(random(6));
					Temp = SpeedRun_Shapes[Current];
					pan_setwindow(SpeedRun_Controls,1,200,150,200,200,Temp,200,200);	
					while(key_any) { wait(1); }	
				}				
			}
			wait(1);	
		}
		
	}
	else
	{
		while(SpeedRun_Controls.alpha > 0)
		{
			SpeedRun_Controls.alpha -= 5;
			SpeedRun_Text.alpha -= 5;
			wait(0.01);	
		}
		Current = integer(random(6));
		Previous = Current;
		reset(SpeedRun_Text,SHOW);
		pan_setdigits(SpeedRun_Controls,1,20,20,"Speed Run - Speed",font_create("Arial#40"),1,sys_seconds);
		pan_setdigits(SpeedRun_Controls,2,150,130,"Remember the new shape",font_create("Arial#30b"),1,sys_seconds);
		Temp = SpeedRun_Shapes[Current];
		pan_setwindow(SpeedRun_Controls,1,200,150,200,200,Temp,200,200);
		while(SpeedRun_Controls.alpha < 100)
		{
			SpeedRun_Controls.alpha += 5;
			wait(0.01);	
		}
		SpeedRun_Running = 1;
	}
}
void SpeedRun_GoGoGo ()
{
	BMAP * TEMP;
	int Current = integer(random(6));
	int Previous = 0;
	
	int Rows;
	int Wrongs;
	int Correct;
	
	
	
	bmap_purge(TEMP);
}
int main ()
{
	mouse_mode = 4;
	set(SpeedRun_GameBackground,SHOW);
	set(SpeedRun_Controls,SHOW);
	set(SpeedRun_Text,SHOW);
	SpeedRun_Shapes[0] = bmap_create("shape1.tga");
	SpeedRun_Shapes[1] = bmap_create("shape2.tga");
	SpeedRun_Shapes[2] = bmap_create("shape3.tga");
	SpeedRun_Shapes[3] = bmap_create("shape4.tga");
	SpeedRun_Shapes[4] = bmap_create("shape5.tga");
	SpeedRun_Shapes[5] = bmap_create("shape6.tga"); 
	while(SpeedRun_GameBackground.alpha != 100)
	{
		SpeedRun_GameBackground.alpha += 5;
		SpeedRun_Controls.alpha +=5;
		SpeedRun_Text.alpha +=5;
		wait(0.01);	
	}
}



1. I set the Time Variable to 45 but in the display it's never changed
2. When I click Right Arrow I want the compare the previous image and the current image,if they are right, I want to ++ Correct else Wrong++.

3.In case of Left Arrow I want to do just the reverse, if they both are same I want to Wrong++, if not same Correct++.

Thanks laugh


Keep smiling laugh
http://translation.babylon.com/ - Translate many languages
Re: Does not do what I except!! [Re: Yashas] #411868
11/20/12 15:03
11/20/12 15:03
Joined: Nov 2011
Posts: 139
India
Yashas Offline OP
Member
Yashas  Offline OP
Member

Joined: Nov 2011
Posts: 139
India
Anyone??


Keep smiling laugh
http://translation.babylon.com/ - Translate many languages
Re: Does not do what I except!! [Re: Yashas] #411883
11/20/12 17:18
11/20/12 17:18
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
I guess nobody is willing to read 200 lines of code. Can you post a complete example (an archive with the required files) or simplifiy the problem description?


Always learn from history, to be sure you make the same mistakes again...
Re: Does not do what I except!! [Re: Uhrwerk] #411921
11/21/12 10:21
11/21/12 10:21
Joined: Nov 2011
Posts: 139
India
Yashas Offline OP
Member
Yashas  Offline OP
Member

Joined: Nov 2011
Posts: 139
India
Code:
void SpeedRun_StartPlay ()
{
	int Previous = 0;
	var Time;// = sys_malloc(sizeof(int));
	var Score; //= sys_malloc(sizeof(int));
	BMAP * Temp; 
	int Row;
	int Correct;
	int Wrong;
	int TechPoints;
	int Current;
	
	//pan_setdigits(SpeedRun_Controls,1,20,20,"Speed Run - Speed","Arial#25b",1,sys_seconds);//sys_seconds for DUMMY - For the sake of a pointer var
	
	//pan_setstring(SpeedRun_Controls,1,100,100,"Arial#25",str_create("Speed Run"));
	//pan_setbutton(SpeedRun_ControlsPlaying,1,0,-100,-100,bmap_create("button1.tga"),bmap_create("button1.tga"),bmap_create("button1.tga"),NULL,NULL,NULL,NULL);
	if(SpeedRun_Running)
	{
		Time = 45;
		Current = integer(random(6));
		//Previous = Current;
		Temp = SpeedRun_Shapes[Current];
		pan_setwindow(SpeedRun_Controls,1,200,150,200,200,Temp,200,200);
		pan_setdigits(SpeedRun_Controls,3,50,70,"Time Remaining:%d",font_create("Arial#30b"),1,Time);
		pan_setdigits(SpeedRun_Controls,4,320,70,"Score:%d",font_create("Arial#30b"),1,Score);
		pan_setdigits(SpeedRun_Controls,5,2000,20,"%f",font_create("Arial#40"),1,sys_seconds);
		pan_setbutton(SpeedRun_Controls,1,0,2000,0,Temp,Temp,Temp,NULL,NULL,NULL,NULL);
		
		while(Time != 0)
		{
			Row = 1;
			Score = 0;
			if(key_cur) //SAME
			{
				if(Current == Previous)
				{
					//Correct
					//AddUserXP(2);
					Score += 5 * Row;
					Row++;
					Correct++;
					TechPoints++;
					Previous = Current;
					Current = integer(random(6));
					Temp = SpeedRun_Shapes[Current];
					pan_setwindow(SpeedRun_Controls,1,200,150,200,200,Temp,200,200);	
					while(key_any) { wait(1); }				
				}
				else
				{
					//Wrong
					//AddUserXP(1);
					Row = 1;
					Score += 5 * Row;
					Wrong++;
					TechPoints--;
					Previous = Current;
					Current = integer(random(6));
					Temp = SpeedRun_Shapes[Current];
					pan_setwindow(SpeedRun_Controls,1,200,150,200,200,Temp,200,200);	
					while(key_any) { wait(1); }				
				}
			}
			else if(key_cul) //NOT SAME
			{
				if(Current == Previous)
				{
					//Wrong
					//AddUserXP(1);
					Row = 1;
					Score += 5 * Row;
					Wrong++;
					TechPoints--;
					Previous = Current;
					Current = integer(random(6));
					Temp = SpeedRun_Shapes[Current];
					pan_setwindow(SpeedRun_Controls,1,200,150,200,200,Temp,200,200);
					while(key_any) { wait(1); }
				}
				else
				{
					//Correct
					//AddUserXP(2);
					Score += 5 * Row;
					Row++;
					Correct++;
					TechPoints++;
					Previous = Current;
					Current = integer(random(6));
					Temp = SpeedRun_Shapes[Current];
					pan_setwindow(SpeedRun_Controls,1,200,150,200,200,Temp,200,200);	
					while(key_any) { wait(1); }	
				}				
			}
			wait(1);	
		}
		
	}
	else
	{
		while(SpeedRun_Controls.alpha > 0)
		{
			SpeedRun_Controls.alpha -= 5;
			SpeedRun_Text.alpha -= 5;
			wait(0.01);	
		}
		Current = integer(random(6));
		Previous = Current;
		reset(SpeedRun_Text,SHOW);
		pan_setdigits(SpeedRun_Controls,1,20,20,"Speed Run - Speed",font_create("Arial#40"),1,sys_seconds);
		pan_setdigits(SpeedRun_Controls,2,150,130,"Remember the new shape",font_create("Arial#30b"),1,sys_seconds);
		Temp = SpeedRun_Shapes[Current];
		pan_setwindow(SpeedRun_Controls,1,200,150,200,200,Temp,200,200);
		while(SpeedRun_Controls.alpha < 100)
		{
			SpeedRun_Controls.alpha += 5;
			wait(0.01);	
		}
		SpeedRun_Running = 1;
	}
}


Here's what I have^^
1. I set Time to 45 but the digits is never updated in the PANEL.
2. Inside "if(SpeedRun_Running)" block, I expect the it to "When I click Right Arrow I want the compare the previous image and the current image,if they are right, I want to ++ Correct else Wrong++." and reverse for left arrow.

CompleteSource with it's required resources:http://www.datafilehost.com/download-90e01251.html


Keep smiling laugh
http://translation.babylon.com/ - Translate many languages
Re: Does not do what I except!! [Re: Yashas] #411939
11/21/12 12:50
11/21/12 12:50
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
This is still pretty much code.

Here is a fast guess: pan_setdigits requires a pointer to a var as its last parameter but you passed a var instead.


Always learn from history, to be sure you make the same mistakes again...
Re: Does not do what I except!! [Re: Uhrwerk] #411951
11/21/12 14:29
11/21/12 14:29
Joined: Nov 2011
Posts: 139
India
Yashas Offline OP
Member
Yashas  Offline OP
Member

Joined: Nov 2011
Posts: 139
India
Thanks

What about the 2nd problem??
Code concerned with the problem(I mean the code which is actually supposed to do tat job of changing window elements)
Code:
while(Time != 0)
		{
			Row = 1;
			Score = 0;
			if(key_cur) //SAME
			{
				if(Current == Previous)
				{
					//Correct
					//AddUserXP(2);
					Score += 5 * Row;
					Row++;
					Correct++;
					TechPoints++;
					Previous = Current;
					Current = integer(random(6));
					Temp = SpeedRun_Shapes[Current];
					pan_setwindow(SpeedRun_Controls,1,200,150,200,200,Temp,200,200);	
					while(key_any) { wait(1); }				
				}
				else
				{
					//Wrong
					//AddUserXP(1);
					Row = 1;
					Score += 5 * Row;
					Wrong++;
					TechPoints--;
					Previous = Current;
					Current = integer(random(6));
					Temp = SpeedRun_Shapes[Current];
					pan_setwindow(SpeedRun_Controls,1,200,150,200,200,Temp,200,200);	
					while(key_any) { wait(1); }				
				}
			}
			else if(key_cul) //NOT SAME
			{
				if(Current == Previous)
				{
					//Wrong
					//AddUserXP(1);
					Row = 1;
					Score += 5 * Row;
					Wrong++;
					TechPoints--;
					Previous = Current;
					Current = integer(random(6));
					Temp = SpeedRun_Shapes[Current];
					pan_setwindow(SpeedRun_Controls,1,200,150,200,200,Temp,200,200);
					while(key_any) { wait(1); }
				}
				else
				{
					//Correct
					//AddUserXP(2);
					Score += 5 * Row;
					Row++;
					Correct++;
					TechPoints++;
					Previous = Current;
					Current = integer(random(6));
					Temp = SpeedRun_Shapes[Current];
					pan_setwindow(SpeedRun_Controls,1,200,150,200,200,Temp,200,200);	
					while(key_any) { wait(1); }	
				}				
			}
			wait(1);	
		}



Keep smiling laugh
http://translation.babylon.com/ - Translate many languages

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1