Message Board
Message Board > Fenix / Bennu / Gemix / DIV > making a menu... |
December 18, 2006, 16:39 | |
Nikki
Whiskered 15 posts |
i have got my 20 buttons working(thanks rincewind) and now i want to be able to know which buttons are on and which one are off. is this the way? starting process. knop(48,12,5,1); fist=x second=y third=graph four=buttonnumber. and in the process If pressed==1 buttonselect.buttonnumber=1, Pff i am ashamed. I am lost [Edited on December 18, 2006 by Nikki] ____________ |
# |
December 18, 2006, 17:53 | |
Eckolin
Quite Whiskered 388 posts |
I suppose that would work.
____________ Maker of Games... Wisdom is supreme; therefore get wisdom. Need help with coding? I probably wrote something similar. |
# |
December 18, 2006, 20:01 | |
Nikki
Whiskered 15 posts |
I am not figuring this out , I keep on getting this struct problems.. Code: PROGRAM muisje; GLOBAL file1; file2; LOCAL STRUCT botselect[20] END; BEGIN full_screen = 1; SET_MODE(320,240,16); file1 = LOAD_FPG("muis.fpg"); file2 = LOAD_FPG("buttons.fpg"); file=file1; mouse.graph=2; knop(48,12,5,1); knop(48,48,1,2); knop(48,60,7,3); knop(48,108,7,4); knop(24,60,9,5); knop(60,60,9,6); knop(24,72,5,7); knop(24,108,3,8); knop(12,120,1,9); knop(72,72,5,10); knop(72,108,3,11); knop(84,120,1,12); knop(24,144,9,13); knop(60,144,9,14); knop(24,156,5,15); knop(72,156,5,16); knop(24,192,5,17); knop(72,192,5,18); knop(12,216,1,19); knop(84,216,1,20); Write_int(0,150,150,0,offset mouse.x); Write(0,175,150,0,"X positie"); Write_int(0,150,160,0,offset mouse.y); Write(0,175,160,0,"y positie"); Loop Frame; End END //------------------------------------------------------- Process knop(x,y,graph,knopvalue); LOCAL //STRUCT botselect[20]=0; Private Flag=0; Pressed=0; Begin File=file2; Loop If (mouse.left and collision(type mouse) and Pressed==0) If (flag==0) flag=1; graph+=1; botselect[knopvalue]=1; Else flag=0; graph-=1; botselect[knopvalue]=0; End Pressed=1; End If (not mouse.left and Pressed==1) Pressed=0; End Frame; End End //-------------------------------------------------------- I want to have a struct, for 20 buttons to know if they are on or off, but i keep on getting these struct required messages, grrrrr ____________ |
# |
December 18, 2006, 20:20 | |
Eckolin
Quite Whiskered 388 posts |
You'll want to use Code: int botselect[20]; as your global then. ____________ Maker of Games... Wisdom is supreme; therefore get wisdom. Need help with coding? I probably wrote something similar. |
# |
December 19, 2006, 11:30 | |
Nikki
Whiskered 15 posts |
I keep on messing about, atleast i don't get compile errors but i still need a little help, Code: PROGRAM muisje; GLOBAL file1; file2; INT botselect[20]; BEGIN set_title("NIKKI tests"); full_screen = 1; SET_MODE(320,240,16); file1 = LOAD_FPG("muis.fpg"); file2 = LOAD_FPG("buttons.fpg"); file=file1; mouse.graph=2; knop(48,12,5,1); knop(48,48,1,2); knop(48,60,7,3); knop(48,108,7,4); knop(24,60,9,5); knop(60,60,9,6); knop(24,72,5,7); knop(24,108,3,8); knop(12,120,1,9); knop(72,72,5,10); knop(72,108,3,11); knop(84,120,1,12); knop(24,144,9,13); knop(60,144,9,14); knop(24,156,5,15); knop(72,156,5,16); knop(24,192,5,17); knop(72,192,5,18); knop(12,216,1,19); knop(84,216,1,20); selector(); Write_int(0,150,150,0,offset mouse.x); Write(0,175,150,0,"X positie"); Write_int(0,150,160,0,offset mouse.y); Write(0,175,160,0,"y positie"); Loop Frame; End END //------------------------------------------------------- Process knop(x,y,graph,knopvalue); Private Flag=0; Pressed=0; Begin File=file2; Loop If (mouse.left and collision(type mouse) and Pressed==0) If (flag==0) flag=1; graph+=1; botselect[knopvalue]=1; say ("poep"); Write_int (0,170,170,0,offset botselect[knopvalue]); Else flag=0; graph-=1; botselect[knopvalue]=0; say ("poep2"); End Pressed=1; End If (not mouse.left and Pressed==1) Pressed=0; End Frame; End End //-------------------------------------------------------- Process selector(); Private loopcounter; Begin //for (loopcounter=0 ; loopcounter=20 ; loopcounter++) if (botselect[loopcounter]==0) write(0, 130,130,0,"pindakaas"); end if (botselect[loopcounter]==1) write(0, 130,130,0,"broodje ham"); end //end frame; end at the beginning i start 20 processes (buttons) these buttons 'know' if they are pressed or not. a write_int proves this, but another process (selector) can only get the initial value of the buttons; which is zero. when i look into the Alt-c there are only 000's and if i try the for loop (which is behind //'s now nothing shows up anymore I am sorry for these basic questions but i tried looking into the maual, the fenixpack tutorials and the spanish help, but i can't grasp it. where do i go wrong? ____________ |
# |
December 19, 2006, 12:36 | |
Dennis
どこかにいる 2092 posts |
1: Your for loop will show nothing because there is no "frame" statement in it. You placed the frame; statment out of the loop. 2: The structure of your for loop is wrong Quoting Nikki: for (loopcounter=0 ; loopcounter=20 ; loopcounter++) I think you rather want: Quoting myself: for (loopcounter=0 ; loopcounter<=20 ; loopcounter++) Fenix is not very supportive yes. I am trying to work on that. [Edited on December 19, 2006 by Dennis] ____________ Kwakkel |
# |
December 19, 2006, 13:27 | |
Sandman
F3n!x0r 1194 posts |
Code: // just to give you some tips, I put some comments in. Some (like the first) // are just alternatives, not meaning your code is wrong. PROGRAM muisje; // PROGRAM statement (with name) is not necessary GLOBAL int file1; int file2; int botselect[20]; // with 20 buttons, you could range this from 0..19 // (int botselect[19] will give you 20 ints 0..19) BEGIN set_title("NIKKI tests"); full_screen = 0; set_mode(320,240,16); // file1 = LOAD_FPG("muis.fpg"); // file2 = LOAD_FPG("buttons.fpg"); file=file1; mouse.graph=new_map(3,3,16); map_clear(0,mouse.graph,rgb(255,0,0)); // the button graphs (I don't have your FPG's) x = new_map(100,10,16); new_map(100,10,16); map_clear(0,x ,rgb(0,255,0)); map_clear(0,x+1,rgb(0,0,255)); set_center(0,x,0,0); set_center(0,x+1,0,0); knop(48,12,x,1); // the knopvalue values could also range from 0..19 knop(48,48,x,2); knop(48,60,x,3); knop(48,108,x,4); // I commented the rest out /* knop(24,60,x,5); knop(60,60,x,6); knop(24,72,x,7); knop(24,108,x,8); knop(12,120,x,9); knop(72,72,x,10); knop(72,108,x,11); knop(84,120,x,12); knop(24,144,x,13); knop(60,144,x,14); knop(24,156,x,15); knop(72,156,x,16); knop(24,192,x,17); knop(72,192,x,18); knop(12,216,x,19); knop(84,216,x,20); */ selector(); // write_int(0,150,150,0,&mouse.x); // I replaced "offset " by "&", it does // the same, but Iuse & because it's the // same in C // write(0,175,150,0,"X positie"); // write_int(0,150,160,0,&mouse.y); // write(0,175,160,0,"y positie"); Loop frame; End END //------------------------------------------------------- Process knop(x,y,graph,knopvalue); Private flag=0; pressed=0; Begin file=file2; // keep the write_int()s out of the loop (write()s too actually, // because you can have a maximum of 512 texts on screen I thought write_int (0,x,y,0,&botselect[knopvalue]); Loop if (mouse.left && collision(type mouse) && Pressed==0) // "and" -> "&&", // same reason, // it's done in C if (botselect[knopvalue]==0) // this is possible because you used // two variablesfor the same thing. // If you want to change thestate of // the button externally the FLAG var // is better perhaps //flag=1; graph+=1; // this can be dangerous in large projects, because // after 2000 (I thought) graphs, it start to fill gaps // (eg the graph 2003 was unloaded, but you have graphs // higher than 2003, and when you load a new one, // that one will become 2003) botselect[knopvalue]=1; say ("poep"); else //flag=0; graph-=1; // idem botselect[knopvalue]=0; say ("poep2"); end pressed=1; end if (!mouse.left && Pressed==1) // "not" -> "!", same reason, // it's done in C Pressed=0; end frame; End End //-------------------------------------------------------- Process selector(); Private loopcounter; string state[20]; // could also be 19 Begin // here we tell to keep a list of strings up to date on the screen // could also be: // for(loopcounter=0;loopcounter<20; loopcounter++) for(loopcounter=1; loopcounter<=20; loopcounter++) write_string(0,10,loopcounter*10-10,0,&state[loopcounter]); end Loop // could also be: // for(loopcounter=0; loopcounter<20; loopcounter++) for(loopcounter=1; loopcounter<=20; loopcounter++) if(botselect[loopcounter]==0) state[loopcounter] = "UNPRESSED"; else state[loopcounter] = "PRESSED"; end end frame; End End [EDIT] Corrected some errors and made the comments 'smaller'. [Edited on December 19, 2006 by Sandman] ____________ BennuWiki Yes, my avatar has grey borders in IE (so get a decent browser) ROOFLEZ ROOFLEZ |
# |
December 19, 2006, 13:36 | |
Nikki
Whiskered 15 posts |
thanks for this example, great [Edited on December 19, 2006 by Nikki] ____________ |
# |
December 19, 2006, 13:46 | |
Dennis
どこかにいる 2092 posts |
Hey I didn't know the statement after PROGRAM was optional. [Edited on December 19, 2006 by Dennis] ____________ Kwakkel |
# |
December 19, 2006, 13:53 | |
Nikki
Whiskered 15 posts |
http://www.filefactory.com/upc/9988c4 are the fpg's and old code, it's for a nifty thingie, but i am a beginner programmer, thanks for this info ____________ |
# |
December 19, 2006, 14:50 | |
Dennis
どこかにいる 2092 posts |
LOL well it looks weird with the pindakaas and all. you can cheat by holding the left mouse button and going over all buttons. I do not like pindakaas, but I am not Dutch either. It reminds me of an android. [Edited on December 19, 2006 by Dennis] ____________ Kwakkel |
# |
December 19, 2006, 15:08 | |
Nikki
Whiskered 15 posts |
well actually i really like that cheat, these buttons reflect a skleton (obviously) and they WILL be part of a simple 2d skeleton animation thing you select a bone (or more) and you can adjust the direction. if you do this more than once you can make simple animation. In the past i have worked with click-things and have created many many little pixel people, when animating all of them i got serious RSI, so i thought this up, now to get it working...... ____________ |
# |
December 19, 2006, 16:53 | |
Sandman
F3n!x0r 1194 posts |
Oh, I see I made a mistake. I wondered why there weren't buttonstate, but it's because: write_string(0,10,10-loopcounter*10,0,&state[loopcounter]); should be write_string(0,10,loopcounter*10-10,0,&state[loopcounter]); . Yes. I'll edit it. [EDIT] I also did <<state="pressed";>> instead of <<state[loopcounter]="pressed";>> [Edited on December 19, 2006 by Sandman] ____________ BennuWiki Yes, my avatar has grey borders in IE (so get a decent browser) ROOFLEZ ROOFLEZ |
# |
Message Board > Fenix / Bennu / Gemix / DIV > making a menu...