本文整理汇总了C++中rest函数的典型用法代码示例。如果您正苦于以下问题:C++ rest函数的具体用法?C++ rest怎么用?C++ rest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rest函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: end_game
/*
There was going to be a nice fadeout effect using the allegro fade_out and
fade_in functions, but for some reason these screwed up the palette. Oh well.
*/
void end_game(int fade_speed)
{
// fade_out(fade_speed);
rest(1000 / fade_speed);
clear_keybuf();
clear_bitmap(screen);
// set_palette(palet);
init_palette();
set_palette(palet);
int challenge_winner = 0;
if (arena[0].teams == 0)
challenge_winner = score_table();
else
challenge_winner = score_table_team();
if (arena[0].challenge_level != 0)
{
if (challenge_winner == 0)
{
switch(arena[0].challenge_level)
{
case 1: information_box("", "Norbert won?", "Hmm.", 0); break;
case 2: information_box("", "Looks like you need some more practice.", "", 0); break;
case 3: information_box("", "Sorry, you lose.", "", 0); break;
case 4: information_box("", "Good, but not great.", "", 0); break;
case 5: information_box("", "Oh well, better luck next time.", "", 0); break;
case 6: information_box("", "Almost there. Try again.", "", 0); break;
case 7: information_box("", "Very good, but not quite good enough.", "", 0); break;
}
end_challenge();
}
}
if (arena[0].qstart != QSTART_NONE)
end_qstart();
//shutdown_network();
// fade_in(*palet, fade_speed);
// set_palette(*palet);
do
{
} while (keypressed() == 0);
clear_keybuf();
//net_init();
}
示例2: countdownEven
void countdownEven(int n) {
if (n == 0) {
printf("0\n");
} else {
if (n % 2 == 0) {
printf("%d ", n);
}
countdownEven(rest(n));
}
}
示例3: init
List *take(int n, List *xs) {
double head = 0;
if (null(xs) || n <= 0) {
return init();
} else {
head = first(ref(xs));
return cons(head, take(n-1, rest(xs)));
}
}
示例4: op_atan
// (atan x)
// (atan x y)
Cell* op_atan(Scheme *sc) {
Cell* x = first(sc->args);
if (rest(sc->args) == &g_nil) {
return s_return_helper(sc, make_real(sc, atan(double_value(x))));
} else {
Cell* y = second(sc->args);
return s_return_helper(sc,
make_real(sc, atan2(double_value(x), double_value(y))));
}
}
示例5: create_bitmap
void SwapScreen::waitForKey(){
BITMAP* textBuf;
textBuf = create_bitmap(150,50);
clear_to_color(textBuf,makecol(255,0,255));
counter=255;
flag=false;
rest(20);
clear_keybuf();
while (!keypressed()){
textprintf_ex(textBuf,font,5,5, makecol(counter,counter,counter), -1, "<Press Any Key>");
draw_sprite(screen,textBuf,160, SCREEN_H/2);
setCounter();
}
rest(20);
destroy_bitmap(textBuf);
}
示例6: controllNave
void controllNave(BITMAP * buffer,BITMAP * nave,SAMPLE * sound, int x,int y){
draw_sprite(buffer, nave,x,y);
int color = 0,s;
if(!key[KEY_SPACE] == 0){
it++;
rest(100);
shotGun(x+20,y-20);
s = play_sample(sound, 100, 0, 2000, 0);
}
}
示例7: bind_vars
static bool bind_vars(obj* vars, obj lt, obj rt){
obj utype;
switch(lt->type){
default:
break;
case tSymbol:
if(macromode){
if(obj rr = search_assoc(car(macro_env), lt)){
//macromode = false;
if(vars) add_assoc(vars, rr, rt);
//macromode = true;
return true;
}
}
if(vars) add_assoc(vars, lt, rt);
return true;
case tRef:
let(&(uref(lt)), rt);
return true;
case INT:
return equal(lt, rt);
case tOp:
utype = search_assoc(curr_interp->types, ult(lt));
if(utype){
if(vrInt(utype) != rt->type) return false;
return bind_vars(vars, urt(lt), uref(rt));
}
if(rt->type!=tOp) return false;
if(! bind_vars(vars, ult(lt), ult(rt))) return false;
return bind_vars(vars, urt(lt), urt(rt));
case LIST:
if(rt->type!=LIST) return false;
list x=ul(lt), a=ul(rt);
for(; (x && a); x=rest(x),a=rest(a)){
if(!bind_vars(vars, first(x), first(a))) return false;
}
if(x||a) return false;
return true;
}
print(lt);
assert(0);
return nil;
}
示例8: GetDlgItem
bool CLoginDialog::registration(){
CString phone, name, email;
int country=((CComboBox*) GetDlgItem(IDC_COUNTRY))->GetCurSel();
GetDlgItemText(IDC_PHONE,phone);
GetDlgItemText(IDC_NAME,name);
GetDlgItemText(IDC_EMAIL,email);
std::string header = "/oneworld/webreg?country=";
header+=countries[country][2];
header+="&number=";
header+=(CT2CA)phone;
header+="&name=";
header+=(CT2CA)name;
header+="&email=";
header+=(CT2CA)email;
header+="&countrycode=";
header+=countries[country][2];
CInternetSession session;
CHttpConnection *pConnection = session.GetHttpConnection(_T("89.163.142.253"));
char result[500];
CString request(header.c_str());
CHttpFile *pFile = pConnection->OpenRequest(1,request);
if(!pFile->SendRequest())
return false;
//pFile->QueryInfo(HTTP_QUERY_FLAG_REQUEST_HEADERS,result,(LPDWORD)500);
#ifdef _DEBUG
pFile->Read((void*)result,500);
_cprintf("%s",result);
#endif
CString rest(result);
int start=rest.Find(_T("success\":\""));
if(start<0)
return false;
start+=((CString)_T("success\":\"")).GetLength();
int end=rest.Find(_T("\""),start);
if(end<0)
return false;
CString success=rest.Mid(start, end-start);
#ifdef _DEBUG
_cprintf("%s",(CT2CA)success);
_cprintf("%s",result);
#endif
start=rest.Find(_T("msg\":\""));
start+=((CString)_T("msg\":\"")).GetLength();
end=rest.Find(_T("\""),start);
CString msg=rest.Mid(start, end-start);
SetDlgItemText(IDC_LOGTEXT,msg);
Sleep(2000);
return true;
}
示例9: main
int main()
{
int koseler[8];
int kirmizi, yesil, mavi, renk;
// Allegro'yu ilklendir
allegro_init();
// klavyeyi ilklendir
install_keyboard();
// rastgele sayı üretecini ilklendir
srand(time(NULL));
// ekran kipini ayarla
int donen = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
if (donen != 0) {
allegro_message(allegro_error);
return;
}
// ekran çözünürlüğünü göster
textprintf(screen, font, 0, 0, 15,
"Cokgen cizme programı - %dx%d - Cikmak icin ESC tusuna basiniz",
SCREEN_W, SCREEN_H);
// çıkış tusuna basılana kadar devam et
while (!key[KEY_ESC]) {
// rastgele bir nokta seç
koseler[0] = 10 + rand() / (RAND_MAX / (SCREEN_W - 20));
koseler[1] = 10 + rand() / (RAND_MAX / (SCREEN_H - 20));
koseler[2] = koseler[0] + rand() / (RAND_MAX / 30) + 50;
koseler[3] = koseler[1] + rand() / (RAND_MAX / 30) + 50;
koseler[4] = koseler[2] + rand() / (RAND_MAX / 30) - 100;
koseler[5] = koseler[3] + rand() / (RAND_MAX / 30) + 50;
koseler[6] = koseler[4] + rand() / (RAND_MAX / 30);
koseler[7] = koseler[5] + rand() / (RAND_MAX / 30) - 100;
// rastgele bir renk seç
kirmizi = rand() / (RAND_MAX / 255 + 1);
yesil = rand() / (RAND_MAX / 255 + 1);
mavi = rand() / (RAND_MAX / 255 + 1);
renk = makecol(kirmizi, yesil, mavi);
// çokgen çiz
polygon(screen, 4, koseler, renk);
rest(50);
}
// programı sonlandır
allegro_exit();
}
示例10: main
int main()
{
allegro_init();
install_keyboard();
set_color_depth(32);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, width, height, 0, 0);
bialy=makecol(200,200,200);
czarny=makecol(0,0,0);//ustawienie kodow kolorow
BITMAP *buffer = create_bitmap(width, height);
clear_to_color(buffer, bialy);
x=width/2;
y=height/2;//ustawienie mrowki w centrum
direction=0;//mrowka zwrocona poczatkowo w gore
while (!keypressed()) {
if(getpixel(buffer,x,y)==bialy)//jesli mrowka znajduje sie na polu bialym
{
//allegro_message("BIALY");
direction = (direction+3)%4;//obrot w lewo
rectfill(buffer,x-0.5*a,y-0.5*a,x+0.5*a,y+0.5*a,czarny);//zamalowanie pola na czarno
}
else{
direction = (direction+5)%4;//obrot w prawo
rectfill(buffer,x-0.5*a,y-0.5*a,x+0.5*a,y+0.5*a,bialy);//zamalowanie pola na bialo
}
x += a*moves[direction][0];
y += a*moves[direction][1];//przesuniecie mrowki w zadanym kierunku
strcpy(napis,"X: ");
strcat(napis,itoa(x,str,10));
strcat(napis," Y: ");
strcat(napis,itoa(y,str,10));
strcat(napis," D: ");
strcat(napis,itoa(direction,str,10));
textout_centre_ex(buffer, font, napis,
SCREEN_W / 2, 0,
makecol(255, 0, 0), makecol(0, 0, 0));
if(x<0.5*a || y<0.5*a || x>width-0.5*a || y>height-0.5*a)break;
//ochrona przed wyjsciem mrowki poza ramy ekranu
blit(buffer, screen, 0, 0, 0, 0, 640, 700);//wklejenie bufora na ekran
rest(10);//odczekanie pomiêdzy kolejnym ruchem
}
readkey();
destroy_bitmap(buffer);
return 0;
}
示例11: keyboard_event_handler
static gint
keyboard_event_handler(GtkWidget *mk, GdkEventKey *event, gpointer ignored)
{
int note;
char *key;
guint keyval;
GdkKeymapKey kk;
PianoKeyboard *pk = PIANO_KEYBOARD(mk);
(void) ignored;
/* We're not using event->keyval, because we need keyval with level set to 0.
E.g. if user holds Shift and presses '7', we want to get a '7', not '&'. */
kk.keycode = event->hardware_keycode;
kk.level = 0;
kk.group = 0;
keyval = gdk_keymap_lookup_key(NULL, &kk);
key = gdk_keyval_name(gdk_keyval_to_lower(keyval));
if (key == NULL) {
g_message("gtk_keyval_name() returned NULL; please report this.");
return FALSE;
}
note = key_binding(pk, key);
if (note < 0) {
/* Key was not bound. Maybe it's one of the keys handled in jack-keyboard.c. */
return FALSE;
}
if (note == 128) {
if (event->type == GDK_KEY_RELEASE) {
rest (pk);
}
return TRUE;
}
note += pk->octave * 12;
assert(note >= 0);
assert(note < NNOTES);
if (event->type == GDK_KEY_PRESS) {
press_key(pk, note);
} else if (event->type == GDK_KEY_RELEASE) {
release_key(pk, note);
}
return TRUE;
}
示例12: menu
void
menu()
{
int a=0;
char s[50],version[]="1.0.8";
//play_sample(themes,255,128,1000,1);
while(1) {
textprintf_centre(screen,font,SREDINA,VISINA/3,15,
" TANKS! v%s",version);
if(a==0) {
textprintf_centre(screen,font,SREDINA,VISINA/3+15,
15,"->Start game",version);
textprintf_centre(screen,font,SREDINA,VISINA/3+30,
15," Exit",version);
}
else {
textprintf_centre(screen,font,SREDINA,VISINA/3+15,
15," Start game",version);
textprintf_centre(screen,font,SREDINA,VISINA/3+30,
15,"->Exit",version);
}
if(key[KEY_ESC])
exit(1);
if(key[KEY_ENTER]) {
if(a==0)
break;
else
exit(1);
}
if(key[KEY_UP]||key[KEY_DOWN]) {
a=!a;
rest(100);
}
}
//stop_sample(themes);
rest(200);
clear(screen);
narisi();
}
示例13: list_walk
int list_walk(LIST *list, list_walk_action action, gptr argument)
{
int error=0;
while (list)
{
if ((error = (*action)(list->data,argument)))
return error;
list=rest(list);
}
return 0;
}
示例14: Abertura
void Abertura (void)
{
BITMAP *buffer;
SAMPLE *som, *grito, *som2, *som3;
buffer = create_bitmap(LARGURA, ALTURA);
carregaSom_Abertura(&som3, "../audio/thunder.wav");
play_sample(som3, 255, 128, 1000, FALSE);
rest (1000);
carregaImg_Abertura(&buffer, "../grafics/img01.tga");
highcolor_fade_in_Abertura(buffer, 3);
carregaSom_Abertura(&som, "../audio/00.wav");
play_sample(som, 255, 128, 1000, FALSE);
carregaSom_Abertura(&som2, "../audio/a_thunder.wav");
play_sample(som2, 255, 128, 1000, FALSE);
rest (2500);
carregaImg_Abertura(&buffer, "../grafics/img02.tga");
play_sample(som, 255, 128, 1000, FALSE);
carregaSom_Abertura(&som, "../audio/01.wav");
play_sample(som, 1000, 128, 1000, FALSE);
carregaSom_Abertura(&grito, "../audio/scream05.wav");
play_sample(grito, 255, 128, 1000, FALSE);
blit(buffer,screen,0,0,0,0,LARGURA,ALTURA);
highcolor_fade_out_Abertura (5);
rest(1000);
destroy_sample(som);
destroy_sample(som2);
destroy_sample(som3);
destroy_sample(grito);
destroy_bitmap(buffer);
}
示例15: while
void LMain::main_loop()
{
while (true) {
undraw();
// Depending on the vsync option, I do either frameskipping or
// a set number of logic cycle calculations.
if (gloB->screen_vsync) {
const unsigned loops = Help::get_timer_ticks_per_draw() + 1;
rest(1);
while (++tck % loops != 0) calc();
// To not have the program hang when the user changes the vsync
// option, set tck here. The following "else" will start working
// immediately in the next main_loop() call then.
if (!gloB->screen_vsync) tck = Help::timer_ticks;
}
// If vsync is deactivated, do normal frameskipping: Calculate until
// the logic is up to date, then draw. If the computer is slow, several
// logic updates will be calcd before the draw.
else {
while (tck == Help::timer_ticks) {
rest(1);
// The mouse poll is something I've inserted here against
// the Yassin bug. The Yassin bug is when clicks from the user
// won't get registered by L++. I hope this helps.
hardware.poll_mouse();
}
while (tck < Help::timer_ticks) {
++tck;
calc();
}
}
if (exit) break;
draw();
}
// This gets uncommented only whenever I want to test for exit crashes.
// clear_to_color(screen, makecol(0, 0, 128));
// rest(400);
}