Page 1 of 1

NXC on windows and mac

Posted: 12 Mar 2011, 22:53
by pesso
Hello. I am making a game. It uses a ric file and the following NXC code. When I compile it in BricxCC I get a different result that if I compile it on a mac using the applescript application John Hansen made. Can someone please explain to me why I get different results.

Code: Select all

#define speedX 5
#define speedY 5
int screen[5];
int jumpstate;
bool onground;
task moveX(){ //Handles X axis of movement
	while(true){
		if(ButtonPressed(BTNLEFT, false)){
			if(screen[3]<=0){
				screen[3]=0;
				if(screen[0]<=7){
					screen[0]=5;
				}else{
					screen[0]-=speedX;
				}
			} else if(screen[3]>=212 && screen[0]>48){
				screen[0]-=speedX;
			} else{
				screen[3]-=speedX;
			}
		} else if(ButtonPressed(BTNRIGHT, false)){
			if(screen[3]>=212){
				screen[3]=212;
				if(screen[0]>=88){
					screen[0]=88;
				} else{
					screen[0]+=speedX;
				}
			} else if(screen[3]<=0 && screen[0]<48){
				screen[0]+=speedX;
			} else{
				screen[3]+=speedX;
			}
		}
		Wait(0146);
	}
}
task moveY(){ //Handles Y axis of movement
	SetSensorTouch(S1);
	onground=true;
	while(true){
		if(onground){
			if(ButtonPressed(BTNCENTER, false)){
				if(screen[4]>=55 | screen[4]<=0){
					if(screen[1]>=20 && !screen[4]>=55){
						if(jumpstate<2){
							screen[4]+=speedY;
						} else{
							screen[4]-=speedY;
						}
						if(jumpstate<3){
							jumpstate+=1;
						} else{
							jumpstate=0;
						}	
					} else{
						if(jumpstate<2){
							screen[1]+=speedY;
						} else{
							screen[1]-=speedY;
						}
						if(jumpstate<3){
							jumpstate+=1;
						} else{
							jumpstate=0;
						}
					}
				} else{            
					if(jumpstate<2){
						screen[4]+=speedY;
					} else{
						screen[4]-=speedY;
					}
					if(jumpstate<3){
						jumpstate+=1;
					} else{
						jumpstate=0;
					}
				}
			} else if(Sensor(S1)==1){
				if(screen[4]>=55){
					screen[4]-=speedY;
				} else{
					screen[1]-=speedY;
				}	
			} else{
				jumpstate=0;
			}
		} else{
			if(screen[4]>60){
				screen[4]-=speedY;
			} else{
				screen[1]-=speedY;
			}
		}
		Wait(0146);
	}
}
task print_graphics(){
	while(true){
		GraphicOutEx(0,0, "smilo_maps.ric",screen);
		Wait(0146);
	}
}
task main(){
	//Default Stuff When Game Is Started
	screen[0]=5;  //Smilo Location X
	screen[1]=5;  //Smilo Location Y
	screen[2]=3;  //screen Sprite Id(2=Empty map, 3=Level 1)
	screen[3]=0;  //screen Scroll X (0-312)
	screen[4]=0;  //screen Scroll Y (0-120)
	Precedes(moveX,moveY,print_graphics);
}

//(X:)62 units by (Y:)24 units
//1488 Squares (62.24)
and happy birthday to jojoguy14 and matelle37

Re: NXC on windows and mac

Posted: 12 Mar 2011, 23:23
by afanofosc
The explanation probably involves different compiler versions or different compiler command line parameters. Can you provide us with both of these bits of information? In theory, if you compile with 1.2.1.r3 on both Mac and Windows and pass exactly the same parameters on the command line then you should get the same results.

John Hansen

Re: NXC on windows and mac

Posted: 12 Mar 2011, 23:27
by m-goldberg
I can't answer your question since you don't tell me what the differences are. However, I have been using the nbc compiler on the Mac for several years with good results. I strongly recommend not using the AppleScripts. They are obsolete. I don't understand why John Hansen still distributes them. One problem with them is that they don't let you set important compiler options. I recommend you run the compiler from the command line using Apple's Terminal application. If you do that you will be able to set the same compiler options as you do with BricxCC. This may solve your problem.

Re: NXC on windows and mac

Posted: 14 Mar 2011, 18:35
by nxtboyiii
Can you post a zip with all the files, including the ric?

Thanks

Re: NXC on windows and mac

Posted: 15 Mar 2011, 18:41
by afanofosc
FYI I have uploaded a new official release of NBC for Mac OSX. Grab it from the http://bricxcc.sourceforge.net/nbc/ page.

John Hansen