本文整理汇总了C++中clearScreen函数的典型用法代码示例。如果您正苦于以下问题:C++ clearScreen函数的具体用法?C++ clearScreen怎么用?C++ clearScreen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clearScreen函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
for( i = 0 ; i < 10 ; i++)
{
//Extraer id local
pos_ini = 1;
pos_fin = Buscar_String( var_transaccion3[i].transaccion, caracter_buscado, pos_ini+1 );
cantidad_caracteres = ((pos_fin - pos_ini) - 1);
substring(variable_destino,var_transaccion3[i].transaccion,pos_ini+1,cantidad_caracteres);
//Almacenamos el variable extraida a la estructura
loc[i].id_local = atoi(variable_destino);
//Extraer nombre local
pos_ini = pos_fin;
pos_fin = Buscar_String( var_transaccion3[i].transaccion, caracter_buscado, pos_ini+1 );
cantidad_caracteres = ((pos_fin - pos_ini) - 1);
substring(variable_destino,var_transaccion3[i].transaccion,pos_ini+1,cantidad_caracteres);
//Almacenamos el variable extraida a la estructura
strcpy(loc[i].nombre_local,variable_destino);
}
//CERRAMOS EL ARCHIVO
fclose(archivo2);
char option;
while(tolower((option=menu()))!='x'){
switch (option){
case 'a':
//caso1
clearScreen();
int mes;
printf("Ingrese un mes entre 1-12: \n");
scanf("%d", &mes);
printf("\n");
if(mes>0 && mes<13)
printf("MES: %s\nTOTAL: $%d\n", meses[mes-1], ventas_mes(ventas, prods, mes));
else
printf("No no no xD, ingresaste un mes fuera de range[1-12]!!!!, mes ingresado ->%d\n", mes );
printf("\n");
system("pause");
clearScreen();
break;
case 'b':
//caso2
printf("");
int cod_buscado;
printf("Ingrese Cod sucursal: \n");
scanf("%d", &cod_buscado);
printf("\n");
buscar_sucursal(loc, cod_buscado);
printf("\n");
system("pause");
clearScreen();
break;
case 'c':
//caso3
printf("");
int dia_b, mes_b, cod_b;//cod local
printf("Ingresar dia: \n");
scanf("%d", &dia_b);
开发者ID:johan16,项目名称:c,代码行数:67,代码来源:main.c
示例2: linenoiseEdit
//.........这里部分代码省略.........
c = fd_read(current);
/* Remove the ^V first */
remove_char(current, current->pos - 1);
if (c != -1) {
/* Insert the actual char */
insert_char(current, current->pos, c);
}
refreshLine(current->prompt, current);
}
}
break;
case ctrl('B'):
case SPECIAL_LEFT:
if (current->pos > 0) {
current->pos--;
refreshLine(current->prompt, current);
}
break;
case ctrl('F'):
case SPECIAL_RIGHT:
if (current->pos < current->chars) {
current->pos++;
refreshLine(current->prompt, current);
}
break;
case SPECIAL_PAGE_UP:
dir = history_len - history_index - 1; /* move to start of history */
goto history_navigation;
case SPECIAL_PAGE_DOWN:
dir = -history_index; /* move to 0 == end of history, i.e. current */
goto history_navigation;
case ctrl('P'):
case SPECIAL_UP:
dir = 1;
goto history_navigation;
case ctrl('N'):
case SPECIAL_DOWN:
history_navigation:
if (history_len > 1) {
/* Update the current history entry before to
* overwrite it with tne next one. */
free(history[history_len - 1 - history_index]);
history[history_len - 1 - history_index] = strdup(current->buf);
/* Show the new entry */
history_index += dir;
if (history_index < 0) {
history_index = 0;
break;
} else if (history_index >= history_len) {
history_index = history_len - 1;
break;
}
set_current(current, history[history_len - 1 - history_index]);
refreshLine(current->prompt, current);
}
break;
case ctrl('A'): /* Ctrl+a, go to the start of the line */
case SPECIAL_HOME:
current->pos = 0;
refreshLine(current->prompt, current);
break;
case ctrl('E'): /* ctrl+e, go to the end of the line */
case SPECIAL_END:
current->pos = current->chars;
refreshLine(current->prompt, current);
break;
case ctrl('U'): /* Ctrl+u, delete to beginning of line, save deleted chars. */
if (remove_chars(current, 0, current->pos)) {
refreshLine(current->prompt, current);
}
break;
case ctrl('K'): /* Ctrl+k, delete from current to end of line, save deleted chars. */
if (remove_chars(current, current->pos, current->chars - current->pos)) {
refreshLine(current->prompt, current);
}
break;
case ctrl('Y'): /* Ctrl+y, insert saved chars at current position */
if (current->capture && insert_chars(current, current->pos, current->capture)) {
refreshLine(current->prompt, current);
}
break;
case ctrl('L'): /* Ctrl+L, clear screen */
clearScreen(current);
/* Force recalc of window size for serial terminals */
current->cols = 0;
refreshLine(current->prompt, current);
break;
default:
/* Only tab is allowed without ^V */
if (c == '\t' || c >= ' ') {
if (insert_char(current, current->pos, c) == 1) {
refreshLine(current->prompt, current);
}
}
break;
}
}
return current->len;
}
开发者ID:pvanek,项目名称:linenoise,代码行数:101,代码来源:linenoise.c
示例3: user_init
void user_init(void)
{
uint8_t i;
UartDev.data_bits = EIGHT_BITS;
UartDev.parity = NONE_BITS;
UartDev.stop_bits = ONE_STOP_BIT;
uart_init(BIT_RATE_9600, BIT_RATE_9600);
i2c_init();
SSD1306Init();
clearScreen();
stringDraw(1, 1, "SDK ver:");
stringDraw(1, 48, (char*)system_get_sdk_version());
ets_uart_printf("reset reason: %d\n", reset_info->reason);
ets_uart_printf("Booting...\n");
ets_uart_printf("SDK version:%s\n", system_get_sdk_version());
setup_wifi_st_mode();
if(wifi_get_phy_mode() != PHY_MODE_11N)
wifi_set_phy_mode(PHY_MODE_11N);
if(wifi_station_get_auto_connect() == 0)
wifi_station_set_auto_connect(1);
#ifdef CONFIG_DYNAMIC
flash_param_t *flash_param;
flash_param_init();
flash_param = flash_param_get();
UartDev.data_bits = GETUART_DATABITS(flash_param->uartconf0);
UartDev.parity = GETUART_PARITYMODE(flash_param->uartconf0);
UartDev.stop_bits = GETUART_STOPBITS(flash_param->uartconf0);
uart_init(flash_param->baud, BIT_RATE_115200);
#else
#endif
ets_uart_printf("size flash_param_t %d\n", sizeof(flash_param_t));
#ifdef CONFIG_GPIO
config_gpio();
#endif
// os_timer_disarm(&timer_1);
// os_timer_setfn(&timer_1, (os_timer_func_t *)timer_1_int, NULL);
// os_timer_arm(&timer_1, 1000, 1);
// Wait for Wi-Fi connection
os_timer_disarm(&WiFiLinker);
os_timer_setfn(&WiFiLinker, (os_timer_func_t *)wifi_check_ip, NULL);
os_timer_arm(&WiFiLinker, 1000, 0);
system_os_task(recvTask, recvTaskPrio, recvTaskQueue, recvTaskQueueLen);
}
开发者ID:LeandroTE,项目名称:ESP8266,代码行数:67,代码来源:user_main.c
示例4: qArrive
int qArrive(Queue *q, productList *products)
{
int code, quantity;
char id[10];
char input;
Customer *c = newCustomer();
Product *p;
basketItem *item;
printf("\n\tEnter customer id:\n\t");
scanf("%s", id);
customerInit(c, id);
clearScreen();
do
{
clearScreen();
printf("\n\tAdd items to bill of '%s'\n", id);
printf("\n\t\tEnter product code: \t(0: quit)\n\t\t");
scanf("%d", &code);
if(code==0)
break;
p=findProductByCode(code, products);
if(p==NULL)
{
printf("Error: Cannot add item to basket.");
wait();
continue;
}
printf("\n\t\tEnter quantity:\n\t\t");
scanf("%d", &quantity);
addToBasket(c, newBasketItem(p, quantity));
printf("\n\t\t%d of %s were added to the basket.", quantity, getProductName(p));
printf("\n\n\t\t[backspace: undo 0: done 1: continue]\n\t\t");
input = getch();
if(input=='\b')
{
remFromBasket(c);
printf("\n\t\tLast item was removed successfully!");
wait();
continue;
}
}while(input!='0');
queueInsert(q, c);
}
开发者ID:nibras-reeza,项目名称:apiit-supermarket-simulation-c,代码行数:61,代码来源:main.c
示例5: main
int main(int argc, char *argv[])
{
/* initialize SDL and its subsystems */
if (SDL_Init(SDL_INIT_EVERYTHING) == -1) die();
if (TTF_Init() == -1) die();
/* set the height and width of the main window, as well as the number
of bits per pixel; this needs to be done prior to initializing the
main window (*screen, below) */
initWindowAttributes();
/* the frame buffer */
SDL_Surface *screen = SDL_SetVideoMode(W_WIDTH, W_HEIGHT,
W_COLOR_DEPTH, SDL_HWSURFACE|SDL_FULLSCREEN);
if (!screen) die();
/* hide the mouse cursor */
SDL_ShowCursor(SDL_DISABLE);
/* the background color of the screen */
const Uint32 clearColor = CLEAR_COLOR(screen->format);
clearScreen(screen, clearColor);
/* clearColor as an SDL_Color, for use with TTF */
Uint8 r, g, b;
SDL_GetRGB(clearColor, screen->format, &r, &g, &b);
SDL_Color bgColor = { r: r, g: g, b: b };
/* the score font */
TTF_Font *font = TTF_OpenFont("resources/VeraMono.ttf", FONT_SIZE);
if (!font) die();
SDL_Color fontColor = FONT_COLOR;
/* the score text; we'll allow three digits plus the terminating '\0' */
char *lScoreStr = malloc(sizeof(char) * 4);
char *rScoreStr = malloc(sizeof(char) * 4);
if (!lScoreStr || !rScoreStr) die();
SDL_Surface *lScore = NULL, *rScore = NULL;
SDL_Rect lScorePos = { x: C_X+FONT_SIZE, y: C_HEIGHT/5,
w: F_WIDTH, h: F_HEIGHT };
SDL_Rect rScorePos = { x: (C_X+C_WIDTH)-3*FONT_SIZE, y: C_HEIGHT/5,
w: F_WIDTH, h: F_HEIGHT };
/* set up the playing court */
Court *court = makeCourt(screen);
if (!court) die();
/* set up the players and their paddles */
Player *lPlayer = makePlayer(screen);
Player *rPlayer = makePlayer(screen);
if (!lPlayer || !rPlayer) die();
rPlayer->paddle.rect.x = C_X + C_WIDTH - P_WIDTH;
/* add the ball */
Ball *ball = makeBall(screen);
if (!ball) die();
/* because SDL_KEY(UP|DOWN) occurs only once, not continuously while
the key is pressed, we need to keep track of whether a key is
(still) pressed */
bool lPlayerShouldMoveUp = false, lPlayerShouldMoveDown = false,
rPlayerShouldMoveUp = false, rPlayerShouldMoveDown = false;
Uint32 startTime; /* denotes the beginning of each iteration
of the main event loop */
bool running = true; /* true till the application should exit */
while (running) {
startTime = SDL_GetTicks();
/* clear the previous frame's paddles and ball */
SDL_FillRect(screen, &lPlayer->paddle.rect, clearColor);
SDL_FillRect(screen, &rPlayer->paddle.rect, clearColor);
SDL_FillRect(screen, &ball->rect, clearColor);
/* clear the previous frame's score */
SDL_FillRect(screen, &lScorePos, clearColor);
SDL_FillRect(screen, &rScorePos, clearColor);
/* redraw the walls in case they were clipped by the ball
in a previous frame */
SDL_FillRect(screen, &court->upperWall, court->color);
SDL_FillRect(screen, &court->lowerWall, court->color);
/* get the current state of the players' controls */
readPlayerInput(&running,
&lPlayerShouldMoveUp, &lPlayerShouldMoveDown,
&rPlayerShouldMoveUp, &rPlayerShouldMoveDown);
/* save the current position of the paddles */
lPlayer->paddle.prevY = lPlayer->paddle.rect.y;
rPlayer->paddle.prevY = rPlayer->paddle.rect.y;
/* move the paddles if appropriate */
if (lPlayerShouldMoveUp)
movePaddle(court, &lPlayer->paddle, UP);
else if (lPlayerShouldMoveDown)
movePaddle(court, &lPlayer->paddle, DOWN);
if (rPlayerShouldMoveUp)
movePaddle(court, &rPlayer->paddle, UP);
else if (rPlayerShouldMoveDown)
//.........这里部分代码省略.........
开发者ID:andereld,项目名称:spong,代码行数:101,代码来源:spong.c
示例6: loadSplash
void loadSplash(void){
clearScreen();
fileRead(fb->top_left, "/rei/splash.bin", 0x46500);
}
开发者ID:bobzhaiyj,项目名称:ReiNand,代码行数:4,代码来源:draw.c
示例7: qFront
int qFront(Queue *q)
{
clearScreen();
printBill(queueFront(q));
wait();
}
开发者ID:nibras-reeza,项目名称:apiit-supermarket-simulation-c,代码行数:6,代码来源:main.c
示例8: clearScreen
void Game::play()
{
Player* p = mLevels[0]->player();
if (p == NULL)
{
mLevels[0]->display();
return;
}
string msg;
bool message, compmessage;
do
{
p->heal();
mLevels[currentlvl]->check_dead_monsters();
clearScreen();
mLevels[currentlvl]->display();
if (message)
{
cout << msg << endl;
message = false;
} else if (compmessage)
{
cout << msg << endl;
compmessage = false;
}
msg = "";
char move = getCharacter();
if (!p->is_sleep())
{
switch (move) {
case 'c': //cheat
p->cheat();
break;
case 'g': //pick up items
message = mLevels[currentlvl]->pick_up(msg);
break;
case 'w': //view use weapons
message = p->showInvent('w', msg);
break;
case 'r': //view scrolls
message = p->showInvent('r', msg);
break;
case 'i': //view inventory
message = p->showInvent('i', msg);
break;
case ARROW_LEFT:
case ARROW_RIGHT:
case ARROW_UP:
case ARROW_DOWN:
message = p->move(move, msg);
break;
case '>':
if(mLevels[currentlvl]->next_level())
{
currentlvl++;
mLevels[currentlvl] = new Levels(currentlvl, p);
mLevels[currentlvl]->add_player();
}
break;
case 'q':
exit(1);
default:
break;
}
}
p->changeSleep(-1);
compmessage = mLevels[currentlvl]->move_monsters(msg);
}
while (!mLevels[currentlvl]->player()->is_dead());
clearScreen();
mLevels[currentlvl]->display();
cout << msg;
cout << "Press q to exit game. " << endl;
char a;
while (a != 'q') {
a = getCharacter();
if (a == 'q')
exit(1);
}
}
开发者ID:michaelwang11394,项目名称:CS-32,代码行数:93,代码来源:Game.cpp
示例9: kmain
kmain()
{
clearScreen();
print("================================================================================\n",0x0F);
print(" Welcome to Q OS\n\n",0x0F);
print("================================================================================\n",0x0F);
while (1)
{
print("\nQ-Kernel> ",0x0F);
string ch = readStr();
if(strEql(ch,"help "))
{
print("\nShowing Help for Q OS ",0x0F);
}
else if(strEql(ch,"do"))
{
print("\n> ",0x0F);
string tmp = readStr();
if(strEql(tmp,"repeat"))
{
print("\nrepeat> ",0x0F);
string tmp = readStr();
nano = 1;
while(1)
{
printch('\n',0x0F);
print(tmp,0x0F);
}
}
if(strEql(tmp,"execute"))
{
print("\n",0x0F);
}
else
{
print("The 'do' command does not support the command you entered or it does not exist ",0x0F);
}
}
else if(strEql(ch,"ls"))
{
print("\nNo Files Found on Disk ",0x0F);
}
else if(strEql(ch,"cd"))
{
print("\nThe specified directory was not found ",0x0F);
}
else if(strEql(ch,"nano"))
{
nano = 1;
clearScreen();
print(" Q-OS Nano Text Editor Version 0.1 ",0xF0);
print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",0x0F);
print(" Built for Q-OS by Raph Hennessy ",0xF0);
cursorX = 0;
cursorY = 1;
updateCursor();
string nanoOutput = readStr();
}
else if(strEql(ch,"clear"))
{
clearScreen();
}
else if(strEql(ch,"sudo"))
{
print("\n",0x0F);
}
else if(strEql(ch,"exit"))
{
print("\n",0x0F);
}
else if(strEql(ch,"run"))
{
print("\n",0x0F);
}
else
{
print("\nCommand Not Found ",0x0F);
}
print("\n",0x0F);
}
}
开发者ID:sreejithmm,项目名称:Q-OS,代码行数:84,代码来源:kernel.c
示例10: planeBall
void planeBall() {
unsigned char x;
clearScreen(black);
// draw a red plane
for (x = 0; x < 5; x++) {
drawLine3D(x, 0, 1,
x, 4, 1, red);
}
fade(5, 10);
swapAndWait(1000);
setVoxel((voxel) {2, 2, 5}, green);
swapAndWait(100);
setVoxel((voxel) {2, 2, 5}, black);
setVoxel((voxel) {2, 2, 4}, green);
swapAndWait(100);
setVoxel((voxel) {2, 2, 4}, black);
setVoxel((voxel) {2, 2, 3}, green);
swapAndWait(100);
setVoxel((voxel) {2, 2, 3}, black);
setVoxel((voxel) {2, 2, 2}, green);
swapAndWait(100);
setVoxel((voxel) {2, 2, 2}, black);
setVoxel((voxel) {2, 2, 3}, green);
swapAndWait(100);
setVoxel((voxel) {2, 2, 3}, black);
setVoxel((voxel) {2, 2, 2}, green);
swapAndWait(1000);
clearImage(black);
for (x = 0; x < 5; x++) {
drawLine3D(x, 0, 0,
x, 4, 2, red);
}
fade(5, 5);
// now the ball has to roll to y = 0
swapAndWait(400);
setVoxel((voxel) {2, 2, 2}, black);
setVoxel((voxel) {2, 1, 2}, green);
swapAndWait(200);
setVoxel((voxel) {2, 1, 2}, black);
setVoxel((voxel) {2, 0, 1}, green);
swapAndWait(1000);
clearImage(black);
for (x = 0; x < 5; x++) {
drawLine3D(x, 0, 1,
x, 4, 1, red);
}
setVoxel((voxel) {2, 0, 2}, green);
fade(5, 5);
swapAndWait(400);
clearImage(black);
for (x = 0; x < 5; x++) {
drawLine3D(x, 0, 2,
x, 4, 0, red);
}
setVoxel((voxel) {2, 0, 3}, green);
fade(5, 5);
swapAndWait(400);
setVoxel((voxel) {2, 0, 3}, black);
setVoxel((voxel) {2, 1, 2}, green);
swapAndWait(200);
setVoxel((voxel) {2, 1, 2}, black);
setVoxel((voxel) {2, 2, 2}, green);
swapAndWait(200);
setVoxel((voxel) {2, 2, 2}, black);
setVoxel((voxel) {2, 3, 1}, green);
swapAndWait(200);
setVoxel((voxel) {2, 3, 1}, black);
setVoxel((voxel) {2, 4, 1}, green);
swapAndWait(200);
setVoxel((voxel) {2, 2, 2}, black);
setVoxel((voxel) {2, 3, 1}, green);
swapAndWait(200);
setVoxel((voxel) {2, 3, 1}, black);
setVoxel((voxel) {2, 4, 1}, green);
swapAndWait(200);
swapAndWait(1000);
clearImage(black);
for (x = 0; x < 5; x++) {
drawLine3D(x, 0, 1,
x, 4, 1, red);
}
setVoxel((voxel) {2, 4, 2}, green);
fade(5, 5);
}
开发者ID:jbornschein,项目名称:farbborg,代码行数:89,代码来源:testAnim.c
示例11: movingCubes
void movingCubes() {
// Startpoint of the cube
voxel cube1 = {0, 0, 0}, cube2 = {3, 3, 3}, cube3 = {0, 3, 3};
direction way[] = {up, right, up, right, up, right,
forward, forward, forward,
down, left, back, down, back, back,
down, left, left, up, right, down, left, 0};
unsigned char i, j;
for (j = 0; j < 5; j++) {
i = 0;
while(way[i]) {
switch (way[i++]) {
case up: cube1.z++;
cube2.x--;
cube3.z--;
if (cube1.z > MAX_Z-1)
cube1.z = 0;
if (cube2.x > MAX_X-1)
cube2.x = 0;
if (cube3.z > MAX_Z-1)
cube3.z = 0;
break;
case down: cube1.z--;
cube2.x++;
cube3.z++;
if (cube1.z > MAX_Z-1)
cube1.z = 0;
if (cube2.x > MAX_X-1)
cube2.x = 0;
if (cube3.z > MAX_Z-1)
cube3.z = 0;
break;
case right: cube1.x++;
cube2.z--;
cube3.x++;
if (cube1.x > MAX_X-1)
cube1.z = 0;
if (cube2.z > MAX_Z-1)
cube2.x = 0;
if (cube3.x > MAX_X-1)
cube3.x = 0;
break;
case left: cube1.x--;
cube2.z++;
cube3.x--;
if (cube1.x > MAX_X-1)
cube1.x = 0;
if (cube2.z > MAX_Z-1)
cube2.z = 0;
if (cube3.x > MAX_X-1)
cube3.x = 0;
break;
case forward: cube1.y++;
cube2.y--;
cube3.y--;
if (cube1.y > MAX_Y-1)
cube1.y = 0;
if (cube2.y > MAX_Y-1)
cube2.y = 0;
if (cube3.y > MAX_Y-1)
cube3.y = 0;
break;
case back: cube1.y--;
cube2.y++;
cube3.y++;
if (cube1.y > MAX_Y-1)
cube1.y = 0;
if (cube2.y > MAX_Y-1)
cube2.y = 0;
if (cube3.y > MAX_Y-1)
cube3.y = 0;
break;
default: break;
}
drawCube(cube1, 0);
drawCube(cube2, 1);
drawCube(cube3, 2);
swapAndWait(110);
clearScreen(black);
}
}
}
开发者ID:jbornschein,项目名称:farbborg,代码行数:83,代码来源:testAnim.c
示例12: switch
/*
* Emulate a single CPU cycle. Frequency = 60 Hz.
*/
void Chip8::emulateCycle()
{
// Fetch the opcode (two bytes, from "pc" location)
current_opcode = memory[pc] << 8 | memory[pc+1];
//We don't need to draw unless 0x00E0 or 0xDXYN are executed.
draw_flag = 0;
v_registers[0xF] = 0;
// Decode and execute the opcode
// "https://en.wikipedia.org/wiki/CHIP-8#Opcode_table"
switch(current_opcode & 0xF000)
{
case 0x0000:
switch(current_opcode & 0x00FF)
{
case 0x00E0:
{
// 00E0 "Clears the screen."
clearScreen();
draw_flag = 1;
pc = pc + 2;
break;
}
case 0x00EE:
{
// 00EE "Returns from a subroutine."
// Set pc to the address at the top of the stack.
// Subtract one from the stack pointer.
pc = stack[sp];
sp = sp - 1;
break;
}
default:
{
// 0NNN "Calls RCA 1802 program at address NNN. Not necessary for most ROMs."
pc = (current_opcode & 0x0FFF);
break;
}
}
break;
case 0x1000:
{
// 1NNN "Jumps to address NNN."
pc = (current_opcode & 0x0FFF);
break;
}
case 0x2000:
{
// 2NNN "Calls subroutine at NNN."
// The stack pointer is incremented by 1.
// The address of the next instruction (current pc + 2) is put on the stack.
// The pc value is set to NNN.
sp = sp + 1;
stack[sp] = pc + 2;
pc = (current_opcode & 0x0FFF);
break;
}
case 0x3000:
{
// 3XNN "Skips the next instruction if VX equals NN."
int registerIndex = (current_opcode & 0x0F00) >> 8;
int immediateVale = (current_opcode & 0x00FF);
if (v_registers[registerIndex] == immediateVale) {
pc = pc + 4;
}
else {
pc = pc + 2;
}
break;
}
case 0x4000:
{
// 4XNN "Skips the next instruction if VX doesn't equal NN."
int registerIndex = (current_opcode & 0x0F00) >> 8;
int immediateVale = (current_opcode & 0x00FF);
if (v_registers[registerIndex] != immediateVale) {
pc = pc + 4;
}
else {
pc = pc + 2;
}
break;
}
case 0x5000:
{
// 5XY0 "Skips the next instruction if VX equals VY."
int registerIndex = (current_opcode & 0x0F00) >> 8;
int registerIndex2 = (current_opcode & 0x00F0) >> 4;
if (v_registers[registerIndex] == v_registers[registerIndex2]) {
pc = pc + 4;
}
else {
pc = pc + 2;
}
break;
//.........这里部分代码省略.........
开发者ID:mjpatter88,项目名称:emu-chip8,代码行数:101,代码来源:Chip8.cpp
示例13: main
int main(int argc, char **argv) {
SDL_Window *win;
SDL_Renderer *g;
int win_width = 1152,
win_height = 720;
int flag_forceinwin = 1,
dtime = 1000;
struct color *renderColor = &GHETTO_WHITE;
struct color *backgroundColor = &GHETTO_BLACK;
// dem args
int c;
while ((c = getopt(argc, argv, "t:yh")) != -1) {
switch (c) {
case 't': // reset delay time
dtime = atoi(optarg);
printf("Delay time set to: %ims\n", dtime);
break;
case 'y': // yolo mode
flag_forceinwin = 0;
printf("YOLO mode intiated\n");
break;
case 'h':
printHelp(argv[0]);
return 0;
default:
break;
}
}
// seed dat RNG
srand((unsigned int) time(NULL));
initSDL();
// grab a window and a renderer
win = getWindow(win_width, win_height);
g = getRenderer(win);
// clear screen
setClearColor(backgroundColor);
clearScreen(g);
// blue lines (for now)
setColor(g, renderColor);
// line number; used to decide direction
// start at 1
int lineNo = 1;
// necesary line node structures for linked list:
// root line node in list
struct node *root = malloc(sizeof(struct node));
// previously generated line node
struct node *previous;
// line node undergoing generation
struct node *current;
// first line, start at middle, rand length, go from there
struct line *firstLine = genNextLine(NULL, lineNo);
// move line to center (genNextLine starts at (0, 0) when
// previous is NULL)
translateLine(firstLine, win_width / 2, win_height / 2);
root->line = firstLine;
root->next = current;
previous = root;
clearScreen(g);
drawLine(g, root->line);
render(g);
// increment line count so loop starts on horizonal
lineNo++;
delay(dtime);
while (1) {
if (!handleEvents())
break;
// allocate memory for new node
current = malloc(sizeof(struct node));
// add to linked list;
// new is old's next
previous->next = current;
if (flag_forceinwin) {
// keep line bound to window bounds
while (1) {
current->line = genNextLine(previous->line, lineNo);
if (current->line->x2 > win_width ||
current->line->y2 > win_height)
//.........这里部分代码省略.........
开发者ID:allekmott,项目名称:LineArt,代码行数:101,代码来源:main.c
示例14: drawTitleScreen
void drawTitleScreen(char* str)
{
clearScreen(0x00);
centerString("HANS",0);
renderString(str, 0, 40);
}
开发者ID:LITTOMA,项目名称:HANS,代码行数:6,代码来源:main.c
示例15: exportCsu
/*!
* \fn void exportCsu()
* Export a csu file into a csv or pdf file
*/
void exportCsu()
{
csuStruct *ptr_csu_struct;
char filename[SIZE_MAX_FILE_NAME];
char export_filename[SIZE_MAX_FILE_NAME];
FileType type;
clearScreen();
// Get the filename
menuFileName(filename);
#ifndef PORTABLE
if(readSystemPath(filename)==false)
return;
#endif // PORTABLE
ptr_csu_struct=readCsuFile(filename);
// Read the file
if (ptr_csu_struct == NULL)
{
systemPause();
return;
}
// Prepare the exportation
strcpy(export_filename,filename);
removeFileExtension(export_filename);
type = menuChooseExportFileType();
if (type == pdf_file)
{
addFilePdfExtension(export_filename);
if (exportToPdf(ptr_csu_struct,export_filename))
printf(_("The file was well export to %s\n"),export_filename);
else
printf(_("There is an error when exporting the file %s into a pdf file.\n"),filename);
}
else if (type == gnuplot_file)
{
if (exportToGnuplotFile(ptr_csu_struct,export_filename))
printf(_("The file was well export to %s\n"),export_filename);
else
printf(_("There is an error when exporting the file %s into gnuplot files.\n"),filename);
}
else if (type == csv_file)
{
addFileCsvExtension(export_filename);
if (exportToCsv(ptr_csu_struct,export_filename))
printf(_("The file was well export to %s\n"),export_filename);
else
printf(_("There is an error when exporting the file %s into a csv file.\n"),filename);
}
else
{
addFileExtension(export_filename,"m");
if (exportToM(ptr_csu_struct,export_filename))
printf(_("The file was well export to %s\n"),export_filename);
else
printf(_("There is an error when exporting the file %s into a m file.\n"),filename);
}
closeCsuStruct(ptr_csu_struct);
systemPause();
}
开发者ID:ludovicdeluna,项目名称:Csuper,代码行数:68,代码来源:interface.c
示例16: single_game
int single_game(){
Audio RRR;
openAudioFile(".\\wav\\RRR.wav", &RRR);
initializeKeyInput();
Character yg = characterMaking1(".\\pic\\yg.pixel",".\\pic\\yg.color");
int key_val[NUM_KEYS]={VK_A,VK_D,VK_ESCAPE};
int stand=0,score=0,standBrick,pDown1,pDown2;
double drop=0,scoreCount=0;
Brick bricks[15];
int i,j,k;
char scoreStr[4]={'0'};
for(i=0;i<10;i++){
bricks[i].y=-1;
bricks[i].w=40;
bricks[i].h=2;
if(i%2==0)bricks[i].color=15;
else if(i<=5)bricks[i].color=8;
else if(i>5)bricks[i].color=12;
else bricks[i].color=10;
}
bricks[0].x=0;
bricks[0].y=100;
Font *large_font=read_font("font.txt");
float lastbrick=0;
int hp = 10,second=0;
float rate=0.15;
while(1){
clearScreen();
srand(clock());
for(i=0;i<10;i++){
if(bricks[i].y>0)bricks[i].y--;
else if(bricks[i].y==0)bricks[i].y=-100;
for(k=0;k<2;k++){
for(j=0;j<bricks[k].w;j++){
putString(bricks[i].x+j,bricks[i].y+k,"=",bricks[i].color,0);
}
}
}
if(score>50){
rate = 0.2;
}
else if(score>75){
rate = 0.25;
}
else if(score>100){
rate = 0.3;
}
if((float)clock()/(float)CLOCKS_PER_SEC-(float)lastbrick>rate&&rand()%10==1){
for(i=0;i<10;i++){
if(bricks[i].y<0){
bricks[i].y=170;
bricks[i].x=rand()%185;
lastbrick=(float)clock()/(float)CLOCKS_PER_SEC;
for(k=0;k<2;k++){
for(j=0;j<bricks[i].w;j++){
putString(bricks[i].x+j,bricks[i].y+k,"=",bricks[i].color,0);
}
}
break;
}
}
}
for(k=0;k<10;k++){
if(abs(yg.y+yg.h-bricks[k].y)<=2&&(
(yg.x+yg.w>bricks[k].x&&yg.x+yg.w<bricks[k].x+bricks[k].w)||
(yg.x>bricks[k].x&&yg.x<bricks[k].x+bricks[k].w))){
stand=1;
standBrick=k;
yg.y=bricks[k].y-yg.h;
break;
}
else if(k==9){
stand=0;
standBrick=-1;
}
}
if(stand==1){
drop=0;
second++;
if(bricks[standBrick].color==15&&second==15){
second=0;
if(hp<10)hp++;
}
else if(bricks[standBrick].color==12){
second++;
if(second==20){
second=0;
hp--;
playAudio(&RRR);
}
}
else if(bricks[standBrick].color==8){
if(second==10){
second=0;
bricks[standBrick].y=-100;
}
}
}
//.........这里部分代码省略.........
开发者ID:hsnuonly,项目名称:BetaCam,代码行数:101,代码来源:main_game.c
示例17: keyboardInput
/**
*
* Function to control the iRobot depending on the character pressed, call it like keyboardInput(serial_getc());
* @param c the character that would determine if the iRobot moves, uses serial_getc()
*/
void keyboardInput(char c)
{
// toggle precision mode, if activated, move is 5 cm and 5 degrees
if(c == 'T')
{
if(precision == 0){
serial_puts("PRECISION ACTIVATED\n\r\n\r");
precision = 1;
}
else{
serial_puts("PRECISION DEACTIVATED\n\r\n\r");
precision = 0;
}
}
// move the iRobot forward, 10 cm
else if(c == 'W')
{
if(precision)
{
serial_puts("MOVING FORWARD 5 CM\n\r\n\r");
moveFowardUpdate(sensor_data, 5);
}
else
{
serial_puts("MOVING FORWARD 10 CM\n\r\n\r");
moveFowardUpdate(sensor_data, 10);
}
wait_ms(100);
}
// move the iRobot backwards, 10 cm
else if(c == 'S')
{
if(precision)
{
serial_puts("MOVING BACKWARD 5 CM\n\r\n\r");
moveBackward(sensor_data, 5);
}
else
{
serial_puts("MOVING BACKWARD 10 CM\n\r\n\r");
moveBackward(sensor_data, 10);
}
wait_ms(100);
}
// rotate the iRobot counter clockwise, 15 degrees
else if(c == 'A')
{
if(precision)
{
serial_puts("TURNING COUNTER CLOCKWISE 5 DEGREES\n\r\n\r");
turn_counter_clockwise(sensor_data, 5); // TODO
}
else
{
serial_puts("TURNING COUNTER CLOCKWISE 15 DEGREES\n\r\n\r");
turn_counter_clockwise(sensor_data, 15); // TODO
}
wait_ms(100);
}
// rotate the iRobot clockwise, 15 degrees
else if(c == 'D')
{
if(precision)
{
serial_puts("TURNING CLOCKWISE 5 DEGREEES\n\r\n\r");
turn_clockwise(sensor_data, 5); // TODO
}
else
{
serial_puts("TURNING CLOCKWISE 15 DEGREEES\n\r\n\r");
turn_clockwise(sensor_data, 15); // TODO
}
wait_ms(100);
}
// start sweeping for ir and sonar data
else if(c == ' ')
{
oi_play_song(0);
serial_puts("SWEEPING FOR OBJECTS\n\r");
smallestObjectSweep();
wait_ms(100);
}
// clear screen
else if(c == '-')
{
clearScreen();
wait_ms(100);
}
//.........这里部分代码省略.........
开发者ID:antkhoun,项目名称:K1-SecretStuff-Don-tFind,代码行数:101,代码来源:FinalProject.c
示例18: main
main()
{
int reg = 0, option = 0;
struct {
char name[50];
char address[50];
int age;
char phone[20];
} customer;
clearScreen();
reg = appMainMenu();
clearScreen();
option = appMenu();
if (reg == CUSTOMER) {
switch (option) {
case INSERT:
clearScreen();
printf("CLIENTES - CADASTRO\n======================\n\n");
printf("Nome: ");
scanf(" %[^\n]s", &customer.name);
//getchar();
printf("Endereço: ");
scanf(" %50[^\n]s", &customer.address);
//getchar();
printf("Idade: ");
scanf(" %d", &customer.age);
//getchar();
printf("Telefone: ");
scanf(" %20[^\n]s", &customer.phone);
//getchar();
FILE *fp;
fp = fopen("files/customer.txt", "a+");
char *record, *age;
sprintf(age, "%d", customer.age);
strcpy(record, "\n");
strcat(record, "1\t\t\t\t");
strcat(record, customer.name);
strcat(record, "\t\t\t\t");
strcat(record, customer.address);
strcat(record, "\t\t\t\t");
strcat(record, age);
strcat(record, "\t\t\t\t");
strcat(record, customer.phone);
fprintf(fp, record);
fclose(fp);
break;
case EDIT:
appPrintf("EDITAR CLIENTE");
break;
case DELETE:
appPrintf("APAGAR CLIENTE");
break;
case SELECT:
appPrintf("SELECIONAR UM CLIENTE");
break;
default:
appPrintf("LISTAR TODOS");
}
}
}
开发者ID:lcdprogrammers,项目名称:Relacionamento-entre-arquivos,代码行数:75,代码来源:main.c
示例19: main
/**
* Main function.
*/
int main(int argc, const char *argv[]) {
int value;
void *cards[6];
initializeAllegroStuff();
zoneAllocatorInitialize();
initializeWadFile(WAD_FILE_PATH);
initializeStaticGraphicsData();
initializeStaticWidgetData();
systemGraphicsSetPalette((unsigned char *)getWadFileLumpContentsByName("PLAYPAL"));
clearScreen();
cards[0] = getWadFileLumpContentsByName("STKEYS0");
cards[1] = getWadFileLumpContentsByName("STKEYS1");
cards[2] = getWadFileLumpContentsByName("STKEYS2");
cards[3] = getWadFileLumpContentsByName("STKEYS3");
cards[4] = getWadFileLumpContentsByName("STKEYS4");
cards[5] = getWadFileLumpContentsByName("STKEYS5");
initializeNumberWidget(&numberWidget, NUMBER_WIDGET_STYLE_SMALL, 100, 10, 10, &value);
value = 1;
drawNumberWidget(&numberWidget);
num
|
请发表评论