NXC on windows and mac

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
pesso
Posts: 8
Joined: 29 Sep 2010, 23:51
Location: Under your Bed

NXC on windows and mac

Post 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
Last edited by pesso on 13 Mar 2011, 21:08, edited 1 time in total.
51st Member Of MindBOARDS! (well, that's that the member's list says)
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXC on windows and mac

Post 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
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
m-goldberg
Posts: 73
Joined: 29 Sep 2010, 12:05

Re: NXC on windows and mac

Post 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.
Regards, Morton
nxtboyiii
Posts: 366
Joined: 02 Oct 2010, 07:08
Location: Everywhere

Re: NXC on windows and mac

Post by nxtboyiii »

Can you post a zip with all the files, including the ric?

Thanks
Thanks, and have a nice day,
nxtboy III

programnxt.com
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXC on windows and mac

Post 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
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests