checksoundbuffer(){
//specific audio hardware stuff, i'm trying to keep things simple.. returns 0 if ready, 1 if busy
}
//2d subsystem drawing
draw{
//if one of the 2d hardware "threads" to put an image is ready, will place it there, or, if the same image is sent will ignore the new issue, and will keep drawing the same image. Otherwise (ie, out of threads will return false)
}
send_audio(){
//will create audio, will return true if audio is emitted, false if not enough buffers/thread, or audio ended.
}
//vars
int script_num=0; //defines the current game's script
int i=0,j=0,z=0,f=0; //loooper
int size_tot_scissors=0; //total of scissors you hold
int size_tot_hair=0; //total of hairstyles you have got at hand
int curr_sciss=0; //current chosen scissor
int curr_hair_indx=0; //current hairtype to be cut chosen
int curr_tilexfrag=0; //current tile x fragment
int curr_tileyfrag=0; //current tile y fragment
//structs
struct currentscissor {
int index=0;
int scissor_x_entry=0; //acts as an entrypoint (coordinate-wise) for (x) currentscissor.index
int scissor_x_limit=0; //acts as a delimiter (coordinate-wise) for (x) currentscissor.index
int scissor_y_entry=0; //same as x entrypoint
int scissor_y_limit=0; //same as x delimiter
}
struct hair{
int index=0; //index, unique value.
int type=0; //0= afro, 1=curly, 2=coily, etc...
int colour=0; //0=blue, 1=green, 2=brown, etc..
}
struct haircut {
int index=comes from index value struct hair has..
int total_fragments=0; //all pieces of hair across a single person's head
int hair_x_entry=0; //acts as an entrypoint (coordinate-wise) for (x) haircut.index
int hair_x_limit=0; //acts as a delimiter (coordinate-wise) for (x) haircut.index
int hair_y_entry=0; //acts as an entrypoint (coordinate-wise) for (y) haircut.index
int hair_y_limit=0; //acts as a delimiter (coordinate-wise) for (y) haircut.index
int hair_tilemap=0; //0 means hair entry on a complete map of hair. every value is delimited by a 16 byte word.
int hair_tilefragment=0; // (hair_fragment_tiley*16)+hair_fragment_tilex), limit for tileY hairfragments is a 16 byte word
//so later round(hair_tilefragment/16) is tileX, and tileY = hair_tilefragment-tileX)
}
//pick current scissor, so it is tied to a certain function, if not chosen returns 1
choose_scissor(curr_sciss,curr_hair_indx){
if(size_tot_scissors==0) return 1; //no scissors were added on the program
//0 cuts little, 1 cuts a chunk
switch (curr_sciss);
case (0);
if(hair.curr_hair_indx!=null){ //hair.curr_hair_indx && haircut.curr_hair_indx are both hair and haircut fragments to be cut
for(z=0;size_tot_hair>z;z++){ //filter the appropiate hair to be cut
for(j=0;j<=haircut.total_fragments;j=j+16){
curr_tilexfrag = round(hair_tilemap[hair_tilefragment+j]/16); //current hair_tileXfragment
curr_tileyfrag = hair_tilemap[hair_tilefragment+j] - curr_tilexfrag;
//with these you can feed the "drawing" to start at given both x and y screen offsets. those will be offered by the drawing engine
draw(curr_tilexfrag,curr_tileyfrag);
//those offsets will be tied to touchscreen x,y
if((hair.index==haircut.index) == curr_hair_indx)
{
if ((touchscreeninput_read() >= hair_x_entry && touchscreeninput_read() <= hair_x_limit) && (touchscreeninput_read() >= hair_y_entry && touchscreeninput_read() <= hair_y_limit))
{
//current hair is removed
haircut.hair_tilemap[hair_tilefragment+j]=0;
haircut.index=0;
}
}//close if tied to touchscreen
}// close cicle hair fragment(j)
return 0;
}//close cicle hair fragment(z)
}//end if curr_hair_indx exists
else if(curr_hair_indx==size_tot_hair) //last thread, hairstyle not found (who knows, someone got rid of that value even if it was there before)
return 1;
}
break;
}
scripting(script_num){
//game behaviour
//stages. say, demo mode (0), intro screen(1), select character(2), stage1(3), stage2(4)... gameover(n-1)
switch(script_num);
case(0);
if(checksoundbuffer()==0) //if there's something on sound buffer, it's sent and done to the audio thread, if not busy.
draw("demo_initscreen");
send_audio("audio_1.etc");
if(touchscreeninput_read().startbutton & 0)
scripting(0); //right here the game will loop on demo mode if start is not pressed.
else {
script_num=1
game_engine(); //if start is pressed, game_engine will be called, and will notice script has changed
}
break;
case(1)
draw("demo_basics");
send_audio("audio_2.etc");
if(touchscreeninput_read().startbutton & 0){
//will wait until audio finishes playing
while(send_audio!=false);
script_num=2;
game_engine();
}
else {
script_num=2
game_engine(); //if start is pressed, game_engine will be called, and will notice script has changed
}
break;
case(2)
//will select characters you will use
if(touchscreeninput_read().startbutton & 1){
script_num=3;
game_engine();
}
else { //if not, we're still on the character screen
script_num=2;
game_engine();
}
break;
case(3)
return true;
break;
case(4)
return true;
break;
}
//basically draws, emit sounds, read controls
game_engine(){
//gameover
if(script_num==(n-1)){
draw("gameover.etc");
send_audio("gameover.etc");
scripting(0);
}
//intro mode
else if(script_num==1)
{
draw.moveacross;
draw.characterdies;
//move character, character dies, i don't know what could happen on the intro.
scripting(1);
}
}
//select character
else if(script_num==2)
{
//load lists of characters be it 2d or 3d you may have..
//draws them on screen, play music.
//wait for a button to be pressed to continue.. but for this we need the scripting
scripting(2);
}
//stage 1
else if(script_num==3)
{
//draws the tools you'll use (on screen)
//draws the coordinates those tools should be used, each coordinate will refer to a specific tool, or scissor in this case
where currentscissor holds the ammount of tools (scissors) you have at hand, with their properties.
for(i=0;i<size_tot_scissors;i++){
if(draw.currentscissor.index==i){
currentscissor.scissor_x_entry=draw.valuex; //actual x coordinate that is being draw
currentscissor.scissor_x_limit=draw.sizeof(valuex); //x top
currentscissor.scissor_y_entry=draw.valuey; //actual y coordinate that is being draw
currentscissor.scissor_y_limit=draw.sizeof(valuey); //y top
}
//draw and tie current scissor map with any function, hair "cut" included as well
choose_scissor();
}
//end stage 1
}
//proceed with other stages
return 1;
}
main(){
video_init(); //if reserved 2d drawing subsystem is not used, will be called (set refresh rate, frames per second, etc), otherwise it isn't called again;
//handles vertical blank or vertical blank interrupt (will tell later the code if this is a cycle for a frame to be drawn, or not).
sound_init(); //same but for the sound subsystem
v_framerefresh(); //will be aware if the current (through a counter) frame is drawn, if not does nothing, else draws a new one)
//enums the ammount of scissors you have at hand
while(draw.currentscissor.index!=null) size_tot_scissors++;
//enums the ammount of hairstyles you have at hand
while(hair.index!=null) size_tot_hair++;
while(game_engine!=1) //the game engine
}
}