Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (7th_zorro, AndrewAMD), 911 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Can t change my material (name changed) #279326
07/17/09 09:56
07/17/09 09:56
Joined: Oct 2008
Posts: 681
Germany
Ayumi Offline OP
User
Ayumi  Offline OP
User

Joined: Oct 2008
Posts: 681
Germany
EDIT:Geaendert, da es einen ungehaltenen User gab, der
mein english in Frage stellt!
(Hatte etliche Jahre englisch aber in den jahren
geht wohl auch der ein oder andere Denkansatz verloren)

Ich habe hier einen Menue code der von der Syntax her
funktioniert aber nicht in seiner Funktionalitaet.

Ich moechte ueber ein Menue 3 Buttons anzeigen lassen
und per switch case function, je nach Button das Material
eines Models zur Laufzeit aendern.
Der Code sollte eigentlich funktionieren allerdings
frage ich mich nun, wieso die if verzweigung nicht funktioniert.

@Schrompf
Enschuldige bitte, das mein englisch fuer deine Verhaeltnisse
nicht gut genug ist.!!!!!!
Das Handbuch hab ich 3 Tage durchgelesen und nichts gefunden.
Und jeder faengt i-wann mal an oder?
Also hoer auf zu meckern.(Auch wenn ich dich verstehen kann)



Code:
var detail;

#define DETAIL_LOW 		0
#define DETAIL_MEDIUM 	        1
#define DETAIL_HIGH		2

PANEL* options_pan = 
{
	bmap = options_tga;
	layer = 30; 
	pos_x = 0;
	pos_y = 0;

        button_radio = 550, 400, low1_tga, low1_tga, low2_tga,menu_detail, NULL, NULL;
	button_radio = 610, 400, med1_tga, med1_tga, med2_tga,menu_detail, NULL, NULL;
	button_radio = 670, 403, high1_tga, high1_tga, high2_tga,menu_detail, NULL, NULL;
}


//count -1(define is 0, start is 1 ...-1 = 0
void menu_detail(var buttonNr)
{
	detail = buttonNr -1;
}

//Switch the buttons
void detail_einstellungen()
{
	switch(detail)
	{
		case DETAIL_LOW:			button_state(options_pan, 1,1);break;
		case DETAIL_MEDIUM:		button_state(options_pan, 2,1);break;
		case DETAIL_HIGH:			button_state(options_pan, 3,1);break;
	}
}

//________


MATERIAL* detail_test1 =
{
	effect = "detail_x.fx";
	event = detail_event;
	flags = ENABLE_RENDER;
}
MATERIAL* detail_test2 =
{
	effect = "empty_technique.fx";
	event = detail_event;
	flags = ENABLE_RENDER;
}


action detail_event()
{
	if(detail == DETAIL_HIGH)
	{
		wait(1);
		my.material = detail_test1;
		my.ambient = 90;
		return;			
	}
	else
		if(detail == DETAIL_MEDIUM)
		{
			wait(1);
			my.material = detail_test2;
			return;
			 
		}else 
			if(detail == DETAIL_LOW)
			{
				wait(1);
				                                            my.material=detail_test2;	
				//d3d_texlimit = 512;
				return;
				
			}	
			
			
	reset(my, DYNAMIC);
	//my.ambient = 90;
}



Last edited by Ayumi; 07/17/09 12:01.
Re: New Problem -.- [Re: Ayumi] #279352
07/17/09 11:29
07/17/09 11:29
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
when you hit a button, you call menu_detail, but this only changes var detail,

and in action detail_event(){ it's only searching on create for which detail it is

so... i'm guessing there's more to you code that creates the level after you've chosen detail, but if not, that's your problem

hope this helps

Re: New Problem -.- [Re: Ayumi] #279353
07/17/09 11:29
07/17/09 11:29
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
Never name your post "New Problem -.-"... but "Materials Problem -.-" or "Menu Problem -.-".


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: New Problem -.- [Re: VeT] #279366
07/17/09 12:01
07/17/09 12:01
Joined: Oct 2008
Posts: 681
Germany
Ayumi Offline OP
User
Ayumi  Offline OP
User

Joined: Oct 2008
Posts: 681
Germany
Thx and sry MrGuest and VeT.

I have edited my post just now.

The function menu_detail is put into the option panel.
Var detail you will see here:switch(detail)
so i think, it s right.
(I have had copy the Syntax example of (switch/ case)
function by the Rudy Game)

I have cleared all code what i don t need to show you.
Here is my code with the Main function:

Code:
var game_started = 0; // will be set to 1 when the game is started
var detail;

#define DETAIL_LOW 		0
#define DETAIL_MEDIUM 	        1
#define DETAIL_HIGH		2


//SStrings
STRING* UT_wmb = "unreal_Aussenlvl1.WMB";

//Function
function mouse_over();

//Main
function main()
{
	fps_max = 60;
	video_mode = 8; 				
	video_depth = 32; 
	video_screen = 1; 
        mouse_spot.x = 1; 
	mouse_spot.y = 1; 

        detail = DETAIL_HIGH; //set to high mode at the beginning
        set (main_pan, VISIBLE);

        vec_set (camera.x, nullvector); // move the camera to the origin
	while (game_started == 0) // this loop runs until the player presses the "New game" button
	{
		camera.pan += 0.1 * time_step; // rotate the camera gently
		camera.tilt += 0.02 * time_step; // on all the axis
		camera.roll += 0.05 * time_step;
		wait (1);
	}
	
}

//function start if pressed the start button on main pan
function start_game() 
{ 

	fps_max = 100;
	reset (main_pan, VISIBLE); 
	
	game_started = 1;
	mouse_mode = 0; 

		wait (1);
	}
	 
	preload_mode = 2;
	
	level_load (UT_wmb); // now load the real level
	wait (3);

	camera.z = 250; // set the camera up high
	camera.tilt = -90; // and then make it look down
}

function mouse_over() // this function runs when we move the mouse over one of the buttons on the panel
{
	snd_play (mouseover_wav, sound_vol, 0);
}	

function mouse_startup() // displays the mouse pointer
{
	mouse_mode = 2;
	mouse_map = cursor_tga;
	while (game_started == 0) // this loop runs until the game is started
	{
		vec_set(mouse_pos, mouse_cursor);
		wait (1); 		      
	}   
}



//the menue codes

PANEL* main_pan = 
{
	bmap = main_tga;
	layer = 20;
	pos_x = 0; 
	pos_y = 0; 
	//button = 52, 28, load1_pcx, load1_pcx, load2_pcx, NULL, NULL, mouse_over;
	//button = 45, 87, save1_pcx, save1_pcx, save2_pcx, NULL, NULL, mouse_over;
	button = 250, 350, new1_pcx, new1_pcx, new2_pcx, start_game, NULL, mouse_over;
	button = 350, 450, options1_pcx, options1_pcx, options2_pcx, set_options, NULL, mouse_over;		
	button = 390, 640, quit1_pcx, quit1_pcx, quit2_pcx, quit_game, NULL, mouse_over;
	button = 380, 550, Help1_tga, Help1_tga, Help2_tga, NULL, NULL, mouse_over;

	flags = OVERLAY;		
}

PANEL* options_pan = 
{
	bmap = options_tga;
	layer = 30; 
	pos_x = 0;
	pos_y = 0;
	
	button_radio = 550, 400, low1_tga, low1_tga, low2_tga,menu_detail, NULL, NULL;
	button_radio = 610, 400, med1_tga, med1_tga, med2_tga,menu_detail, NULL, NULL;
	button_radio = 670, 403, high1_tga, high1_tga, high2_tga,menu_detail, NULL, NULL;
	
	flags = OVERLAY;
}


// var detail for menue_detail, set in PANEL* options_pan
void menu_detail(var buttonNr)
{
	detail = buttonNr -1;
}

void detail_einstellungen()
{
	switch(detail)
	{
		case DETAIL_LOW:			button_state(options_pan, 1,1);break;
		case DETAIL_MEDIUM:		button_state(options_pan, 2,1);break;
		case DETAIL_HIGH:			button_state(options_pan, 3,1);break;
	}
}


//set Material 
//Detailmapping
//ENABLE_RENDER flag for switch material 

MATERIAL* detail_test1 =
{
	effect = "detail_x.fx";
	event = detail_event;
	flags = ENABLE_RENDER;
}
MATERIAL* detail_test2 =
{
	effect = "empty_technique.fx";
	event = detail_event;
	flags = ENABLE_RENDER;
}


action detail_event()
{
	if(detail == DETAIL_HIGH)
	{
		wait(1);
		my.material = detail_test1;
		my.ambient = 90;
		return; 			
	}
	/*
	else
		if(detail == DETAIL_MEDIUM)
		{
			wait(1);
			detail_test2 = mtl_create();
			return;
			 
		}else 
			if(detail == DETAIL_LOW)
			{
				wait(1);
				detail_test2 = mtl_create();
				return;
				
			}	
			*/
			
	reset(my, DYNAMIC);
	//my.ambient = 90;
}



Re: New Problem -.- [Re: Ayumi] #279377
07/17/09 12:41
07/17/09 12:41
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
DYNAMIC: You don`t can reset the DYNAMIC flag and then change the material after... From the Manual: Statische Entities erlauben keine Events - einschließlich Materialevents.
function: from where you call the function detail_einstellungen() ? I don`t can find that.
material: Why is detail_event() a action and not a void / function?

Re: New Problem -.- [Re: Widi] #279385
07/17/09 12:58
07/17/09 12:58
Joined: Oct 2008
Posts: 681
Germany
Ayumi Offline OP
User
Ayumi  Offline OP
User

Joined: Oct 2008
Posts: 681
Germany
1) Oh, that i havn t known.I will clear it.

2) Maybe through "detail = buttonNr -1;"->switch(detail)???

3) It works with both.(Void,function,action)
But i have changed to function.

Btw:I am a noob for lite c code.(I am still learning).
thx for your answer.

Last edited by Ayumi; 07/17/09 13:02.
Re: New Problem -.- [Re: Ayumi] #279389
07/17/09 13:07
07/17/09 13:07
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
3: yes, it works both. The only different is that a action is show up in the WED Properties... But it is more "sauberes programmieren" if you use always the right one.

2: Sorry, whrite now in german, can better explain it (my english is not sooo good). Ich glaube du hast mich falsch verstanden. Du musst ja die Function detail_einstellungen() irgendwo aufrufen, aber wo? So wird diese Function gar nie durchgeführt!

Re: New Problem -.- [Re: Widi] #279428
07/17/09 15:39
07/17/09 15:39
Joined: Oct 2008
Posts: 681
Germany
Ayumi Offline OP
User
Ayumi  Offline OP
User

Joined: Oct 2008
Posts: 681
Germany
Mhm danke.

Ja, den englischen usern zu liebe ist es ok, in englisch zu schreiben;)

Ich hab dich richtig verstanden und dein englisch war i.O.
Meins is auch nicht besser^^

Ja du wirst lachen, aber die Frage wo diese unction aufgerufen wird ,
habe ich mich auch schon gefragt.

Im Rudi game wird diese in i-einer anderen Function aufgerufen
aber konnte damit nichts anfangen.
Und es bringt mir leider auch nicht wirklich was, diese in der main
aufzurufen aber ich teste nochmal durch.

Re: New Problem -.- [Re: Ayumi] #279450
07/17/09 17:06
07/17/09 17:06
Joined: Oct 2008
Posts: 681
Germany
Ayumi Offline OP
User
Ayumi  Offline OP
User

Joined: Oct 2008
Posts: 681
Germany
Nein, ich kann machen was ich will aber es aendert nicht sein
Material.

Punkte bisher ausgefuehrt:

- Eine Action geschrieben, die die Function als event function definiert
- Die Function der Case function in der Main Function gesetzt
- nur mit einer If verzweigung getestet
- "my.material" zu "mtl" ausgetauscht(wie es im Handbuch steht)
- wait anweisungen entfernt

Re: New Problem -.- [Re: Ayumi] #279459
07/17/09 18:13
07/17/09 18:13
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
try this:
Code:
MATERIAL* detail_test1 =
{
	effect = "detail_x.fx";
}
MATERIAL* detail_test2 =
{
	effect = "empty_technique.fx";
}

void menu_detail(var buttonNr)
{
 	my = POINTER_ZU_DEINEM_MODEL;   // player?
	detail = buttonNr -1;
	switch(detail)
	{
		case DETAIL_LOW:	my.material = detail_test1;   button_state(options_pan, 1,1);   break;
		case DETAIL_MEDIUM:	my.material = detail_test1;   button_state(options_pan, 2,1);   break;
		case DETAIL_HIGH:	my.material = detail_test1;   button_state(options_pan, 3,1);   break;
	}
}


PANEL* options_pan = 
{
	bmap = options_tga;
	layer = 30; 
	pos_x = 0;
	pos_y = 0;
	
	button_radio = 550, 400, low1_tga, low1_tga, low2_tga,menu_detail, NULL, NULL;
	button_radio = 610, 400, med1_tga, med1_tga, med2_tga,menu_detail, NULL, NULL;
	button_radio = 670, 403, high1_tga, high1_tga, high2_tga,menu_detail, NULL, NULL;
	
	flags = OVERLAY;
}



Last edited by Widi; 07/17/09 18:20.
Page 1 of 2 1 2

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