本文整理汇总了C++中clear_to_color函数的典型用法代码示例。如果您正苦于以下问题:C++ clear_to_color函数的具体用法?C++ clear_to_color怎么用?C++ clear_to_color使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clear_to_color函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int main(void)
{
int i,j,k,x,y;
//byte bi,bj;
//byte cursize=1;
//int cursorx=0,cursory=0;
//byte spritecont=10,spritecont2=10+16;
//byte sprconmeno,sprconpiu;
//byte sprconmeno2,sprconpiu2;
//byte terrancont=0,solidcont=0;
//bool speed=false;
//bool print=false,toggleprint=false;
//bool moved=false,pushed=false;
int nlevel;
BITMAP *buffer; // Double-buffering
BITMAP *textures; // Immagine globale delle texture
BITMAP *sprites[256]; // Array degli sprite
//RGB color[256];
//char nomefile[30],errmess[20];
//FILE *fp;
T_Map mappa;
strcpy(errmess,""); // inizializzo la stringa
if(!mappa.InitLevel()){
strcpy(errmess,"Impossibile allocare la mappa");
exit(0);
}
/////////// INPUT NOME FILE DELLA MAPPA ///////////////////////
printf("\n\t Inserta il nome del file della mappa(senza est.) : ");
gets(nomefile);
strcat(nomefile,".map");
/////////////////////////////////////////////////////////////////
if(!mappa.SetMapFile){
printf("\n\t File non trovato");
}
nlevel=mappa.RetNLevel();
printf("\n\t Numero attuale di livelli: %d",nlevel);
printf("\n\t Inserta il numero di livelli da creare nella mappa:");
printf("\n\t (0 per non aggiungerne)");
scanf("%d",&i);
if(i>0){
nlevel+=i;
mappa.SetNLevel(nlevel);
mappa.AllocMap();
}
GameInit();
textures=create_bitmap(128,128);
mappa.SetTextureFile("D:\\DJGPP\\Game01\\IndexTxt.txt");
/////// Gestione delle texture... s�, lo so, lo so che sono tile
for(y=0,i=0;y<16&&i<256;y++){
for(x=0;x<16&&i<256;x++,i++){
sprites[i]=create_sub_bitmap(textures,x*UNITX,
y*UNITY,UNITX,UNITY);
}
}
/////////// INIZIALIZZAZIONE MATRICE DELLA FINESTRELLA /////
for(i=0;i<WIMGY;i++){
for(j=0;j<WIMGX;j++){
miniwmask[i][j]=0;
}
}
////// INIZIALIZZAZIONE MATRICE DELLA LISTA DELLE TILE/////////////
for(i=0;i<2;i++){
for(j=0;j<20;j++){
spritemask1[i][j]=0;
spritemask2[i][j]=0;
}
}
///////////////// BUFFER PER IL DOUBLE BUFFERING //////////////
buffer=create_bitmap(SCREEN_W,SCREEN_H);
//show_mouse(buffer);
clear_to_color(buffer,DESK_COL);
//clear_to_color(lvldis,BACKG_COL);
//.........这里部分代码省略.........
开发者ID:Shaduck,项目名称:OldGame01,代码行数:101,代码来源:NwLvlMak.cpp
示例2: SpaceLocation
KaboHaze::KaboHaze(SpaceLocation *creator, Ship *ohost, double obasepower)
:
SpaceLocation(creator, Vector2(0.0, 0.0), 0.0)
{
STACKTRACE;
prev = 0;
next = 0;
// update the list (insert at the start)
if (KaboHazeFirst)
KaboHazeFirst->prev = this;
next = KaboHazeFirst;
prev = 0;
KaboHazeFirst = this;
//mother = omother;
host = ohost;
basepower = obasepower;
power = basepower;
// decay_time = odecaytime; // in milliseconds
newcrew = iround(host->getCrew());
oldcrew = newcrew;
// this "haze" is passive, of course:
collide_flag_anyone = 0;
collide_flag_sameteam = 0;
collide_flag_sameship = 0;
// I'll make 64 rotated versions in total, if needed, which I'll store
// in memory:
for ( int i = 0; i < 64; ++i ) {
shield_bmp[i] = 0;
}
sprite_index = 0; // no rotation.
shield_sprite_index = 0;
// this item cannot collide
collide_flag_anyone = 0;
// this is probably important ... otherwise a thing like a flipping wedge indicator
// can avoid a shield from being drawn ?!?!
layer = LAYER_SHIPS;
set_depth(DEPTH_SHIPS + 0.1);
// The +0.1 places this presence at a higher level, so that this routine is
// always done after the ship was drawn! Thnx Orz, for telling.
// Graphics init stuff for the shield !
// copy the ship sprite (yes, a COPY because we need to do some operations on it !)
SpaceSprite *ship_spr;
ship_spr = host->get_sprite();
if (!ship_spr) {
state = 0;
return;
}
//BITMAP *ship_bmp;
int wship = ship_spr->width();
int hship = ship_spr->height();
BITMAP *ship_bmp = create_bitmap(wship, hship);
clear_to_color(ship_bmp, 0); // important otherwise it contains artefacts
int index = 0;
ship_spr->draw(Vector2(0, 0), Vector2(wship, hship), index, ship_bmp);
// this does a (masked?) blit
// create a blurred image from this:
int R = 3;
blit_blur(ship_bmp, R); // a complex and costly funtion ! Inefficiently programmed as well of course (by me).
// now, create a masked shield - only the area that covers the
// blurred image of the ship:
shield_bmp[sprite_index] = create_bitmap(wship, hship);
// important otherwise it contains artefacts
clear_to_color(shield_bmp[sprite_index], 0);
// scale/draw a shield:
/*
// the raw shield image
BITMAP *raw_bmp = this->sprite->get_bitmap_readonly(0);
int wraw = raw_bmp->w;
int hraw = raw_bmp->h;
stretch_blit(raw_bmp, shield_bmp[sprite_index], 0, 0, wraw, hraw, 0, 0, wship, hship );
*/
// a uniform green glow
clear_to_color(shield_bmp[sprite_index], tw_makecol(0,255,0));
// mask out the areas outside the ship, so that the shield only covers
//.........这里部分代码省略.........
开发者ID:Yurand,项目名称:tw-light,代码行数:101,代码来源:shpkabwe.cpp
示例3: main
int main()
{
int exit_flag = 0, i;
VERTEX cube[8];
cube[0].local = (_3D) {
-10.0, -10.0, 0.0
};
cube[1].local = (_3D) {
10.0, -10.0, 0.0
};
cube[2].local = (_3D) {
10.0, 10.0, 0.0
};
cube[3].local = (_3D) {
-10.0, 10.0, -10.0
};
cube[4].local = (_3D) {
-10.0, -10.0, 10.0
};
cube[5].local = (_3D) {
10.0, -10.0, 10.0
};
cube[6].local = (_3D) {
10.0, 10.0, 10.0
};
cube[7].local = (_3D) {
-10.0, 10.0, 10.0
};
_3D world_pos = {0.0, 0.0, 100.0};
init();
printf("D1:=%f;\nD2:=%f;\nD3:=%f;\nD4:=%f;\n", dist_3d(cube[0].local, cube[1].local),
dist_3d(cube[1].local, cube[2].local),
dist_3d(cube[2].local, cube[3].local),
dist_3d(cube[3].local, cube[0].local));
readkey();
int xang, yang, zang;
while(!exit_flag)
{
rest(10);
xang = 0;
yang = 0;
zang = 0;
if(keypressed())
{
if(key[KEY_ESC]) {
exit_flag = 1;
}
if(key[KEY_A]) {
world_pos.x -= 1.0;
}
if(key[KEY_D]) {
world_pos.x += 1.0;
}
if(key[KEY_W]) {
world_pos.z += 3.0;
}
if(key[KEY_S]) {
world_pos.z -= 3.0;
}
if(key[KEY_UP]) {
xang = 3;
}
if(key[KEY_DOWN]) {
xang = -3;
}
if(key[KEY_RIGHT]) {
yang = 3;
}
if(key[KEY_LEFT]) {
yang = -3;
}
}
clear_to_color(buffer, 0);
for(i = 0; i < 8; i++)
{
rotate_vertex(&cube[i], xang, yang, zang);
project_vertex(&cube[i], world_pos);
}
/*
printf("%f, %f, %f\n", dist_3d(cube[0].local, cube[1].local),
dist_3d(cube[1].local, cube[2].local),
dist_3d(cube[2].local, cube[0].local));
*/
printf("Sx1:=%f;\nSy1:=%f;\nSx2:=%f;\nSy2:=%f;\nSx3:=%f;\nSy3:=%f;\nSx4:=%f;\nSy4:=%f;\n", cube[0].screen[0].x, cube[0].screen[0].y,
cube[1].screen[0].x, cube[1].screen[0].y,
cube[2].screen[0].x, cube[2].screen[0].y, cube[3].screen[0].x, cube[3].screen[0].y);
//.........这里部分代码省略.........
开发者ID:omer4d,项目名称:SuperOldCode,代码行数:101,代码来源:test3d.c
示例4: switch
bool Tabs::onProcessMessage(Message* msg)
{
SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
switch (msg->type) {
case JM_REQSIZE:
msg->reqsize.w = 0; // msg->reqsize.h = 4 + jwidget_get_text_height(widget) + 5;
msg->reqsize.h =
theme->get_part(PART_TAB_FILLER)->h +
theme->get_part(PART_TAB_BOTTOM_NORMAL)->h;
return true;
case JM_SETPOS:
jrect_copy(this->rc, &msg->setpos.rect);
setScrollX(m_scrollX);
return true;
case JM_DRAW: {
BITMAP *doublebuffer = create_bitmap(jrect_w(&msg->draw.rect),
jrect_h(&msg->draw.rect));
JRect rect = jwidget_get_rect(this);
jrect_displace(rect, -msg->draw.rect.x1, -msg->draw.rect.y1);
JRect box = jrect_new(rect->x1-m_scrollX,
rect->y1,
rect->x1-m_scrollX+2*jguiscale(),
rect->y1+theme->get_part(PART_TAB_FILLER)->h);
clear_to_color(doublebuffer, theme->get_window_face_color());
theme->draw_part_as_hline(doublebuffer, box->x1, box->y1, box->x2-1, box->y2-1, PART_TAB_FILLER);
theme->draw_part_as_hline(doublebuffer, box->x1, box->y2, box->x2-1, rect->y2-1, PART_TAB_BOTTOM_NORMAL);
box->x1 = box->x2;
// For each tab...
TabsListIterator it, end = m_list_of_tabs.end();
for (it = m_list_of_tabs.begin(); it != end; ++it) {
Tab* tab = *it;
box->x2 = box->x1 + tab->width;
int x_delta = 0;
int y_delta = 0;
// Y-delta for animating tabs (intros and outros)
if (m_ani == ANI_ADDING_TAB && m_selected == tab) {
y_delta = (box->y2 - box->y1) * (ANI_ADDING_TAB_TICKS - m_ani_t) / ANI_ADDING_TAB_TICKS;
}
else if (m_ani == ANI_REMOVING_TAB && m_nextTabOfTheRemovedOne == tab) {
x_delta += m_removedTab->width - m_removedTab->width*(1.0-std::exp(-10.0 * m_ani_t / (double)ANI_REMOVING_TAB_TICKS));
x_delta = MID(0, x_delta, m_removedTab->width);
// Draw deleted tab
if (m_removedTab) {
JRect box2 = jrect_new(box->x1, box->y1, box->x1+x_delta, box->y2);
drawTab(doublebuffer, box2, m_removedTab, 0, false);
jrect_free(box2);
}
}
box->x1 += x_delta;
box->x2 += x_delta;
drawTab(doublebuffer, box, tab, y_delta, (tab == m_selected));
box->x1 = box->x2;
}
if (m_ani == ANI_REMOVING_TAB && m_nextTabOfTheRemovedOne == NULL) {
// Draw deleted tab
if (m_removedTab) {
int x_delta = m_removedTab->width - m_removedTab->width*(1.0-std::exp(-10.0 * m_ani_t / (double)ANI_REMOVING_TAB_TICKS));
x_delta = MID(0, x_delta, m_removedTab->width);
JRect box2 = jrect_new(box->x1, box->y1, box->x1+x_delta, box->y2);
drawTab(doublebuffer, box2, m_removedTab, 0, false);
jrect_free(box2);
box->x1 += x_delta;
box->x2 = box->x1;
}
}
/* fill the gap to the right-side */
if (box->x1 < rect->x2) {
theme->draw_part_as_hline(doublebuffer, box->x1, box->y1, rect->x2-1, box->y2-1, PART_TAB_FILLER);
theme->draw_part_as_hline(doublebuffer, box->x1, box->y2, rect->x2-1, rect->y2-1, PART_TAB_BOTTOM_NORMAL);
}
jrect_free(rect);
jrect_free(box);
blit(doublebuffer, ji_screen, 0, 0,
msg->draw.rect.x1,
msg->draw.rect.y1,
doublebuffer->w,
doublebuffer->h);
//.........这里部分代码省略.........
开发者ID:optigon,项目名称:aseprite,代码行数:101,代码来源:tabs.cpp
示例5: clear_to_color
void Layer::draw(BITMAP * dest)
{
// default implementation: clear blue
clear_to_color (dest, BLUE);
}
开发者ID:GassaFM,项目名称:TINS-is-not-speedhack-2012,代码行数:5,代码来源:layer.cpp
示例6: main
int main()
{
int klaw = 0;
allegro_init();
install_keyboard();
set_color_depth(16);
set_gfx_mode(GFX_AUTODETECT,640,480,0,0);
clear_to_color(screen,makecol(10,10,10));
while( !key[KEY_ESC])
{
/* klaw = readkey();
clear_to_color(screen,makecol(10,10,10));
switch (klaw) {
case 7217:
textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : 1");
break;
case 7474:
textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : 2");
break;
case 7731:
textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : 3");
break;
case 7988:
textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : 4");
break;
case 8245:
textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : 5");
break;
}
if( key[KEY_LEFT]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_LEFT]");
if( key[KEY_RIGHT]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_RIGHT]");
if( key[KEY_UP]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_UP]");
if( key[KEY_DOWN]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_DOWN]");
if( key[KEY_0]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_0]");
if( key[KEY_1]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_1]");
if( key[KEY_2]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_2]");
if( key[KEY_3]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_3]");
if( key[KEY_4]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_4]");
if( key[KEY_5]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_5]");
if( key[KEY_6]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_6]");
if( key[KEY_7]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_7]");
if( key[KEY_8]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_8]");
if( key[KEY_9]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_9]");
if( key[KEY_SPACE]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_SPACE]");
if( key[KEY_ENTER]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_ENTER]"); */
BITMAP *plik = NULL;
plik = load_bmp("bmp.bmp",default_palette);
if (!plik)
{
set_gfx_mode(GFX_TEXT,0,0,0,0);
allegro_message("nie mogê za³adowaæ obrazka Plik!");
allegro_exit();
return 0;
}
blit( plik, screen, 0,0, 100,100, plik->w, plik->h);
readkey();
destroy_bitmap(plik);
allegro_exit();
}
allegro_exit();
//.........这里部分代码省略.........
开发者ID:hasiek,项目名称:III-sem,代码行数:101,代码来源:main+-+klawiatura.c
示例7: select_a_ship
int select_a_ship(void)
{
int ship_box [8] = {0,0,0,0,0,0,0,0};
int sbox2;
int ship_chosen = 0;
int level_chosen = 1;
int max_level, wpixels;
menu_counter = 0;
counter2 = 0;
int anykey = 0;
int i, x, y, k;
int holding_key = 1;
while (TRUE)
{
menu_counter ++;
clear_to_color(display, COL_BACK1);
run_menu_background();
x = 30;
y = 40;
#define Y_INTERVAL 100
#define Y_BASE 45
// stages
aabox(200, 50, 550, 250);
TRANS_MODE
rectfill(display, 375 - 80, 70, 375 + 80, 100, TRANS_BLUE2);
rect(display, 375 - 80, 70 - 0, 375 + 80, 100, TRANS_BLUE3);
rect(display, 375 - 81, 70 - 1, 375 + 81, 100 + 1, TRANS_BLUE2);
END_TRANS
textprintf_centre_ex(display, font, 375, 80, -1, -1, "select stage");
switch(arena.difficulty)
{
case 0: textprintf_centre_ex(display, font, 375, 115, -1, -1, "NORMAL"); break;
case 1: textprintf_centre_ex(display, font, 375, 115, -1, -1, "HARD"); break;
case 2: textprintf_centre_ex(display, font, 375, 115, -1, -1, "PUNISHMENT"); break;
}
for (i = 0; i < 3; i ++)
{
if (i == 0)
{
aabox(230 + i * 70, 140 + i * 25, 270 + i * 70, 180 + i * 25);
textprintf_centre_ex(display, font, 250 + i * 70, 152 + i * 25, -1, -1, "%i", i + 1);
rect(display, 276 + i * 70, 141 + i * 25, 302 + i * 70, 152 + i * 25, TRANS_BLUE3);
}
else
if (options.stage_power [ship_chosen] [i - 1] [arena.difficulty] != 0 || options.stage_power_bar [ship_chosen] [i - 1] [arena.difficulty] != 0)
{
aabox(230 + i * 70, 140 + i * 25, 270 + i * 70, 180 + i * 25);
if (options.stage_power [ship_chosen] [i - 1] [arena.difficulty] < 0 || options.stage_power [ship_chosen] [i - 1] [arena.difficulty] > 9)
options.stage_power [ship_chosen] [i - 1] [arena.difficulty] = 0; // sanity check
textprintf_centre_ex(display, font, 250 + i * 70, 152 + i * 25, -1, -1, "%i", i + 1);
TRANS_MODE
for (k = 0; k < options.stage_power [ship_chosen] [i - 1] [arena.difficulty]; k ++)
{
rectfill(display, 305 + i * 70 + k * 4, 143 + i * 25, 307 + i * 70 + k * 4, 150 + i * 25, TRANS_RED1);
rect(display, 305 + i * 70 + k * 4, 143 + i * 25, 307 + i * 70 + k * 4, 150 + i * 25, TRANS_RED4);
}
// rect(display, 275 + i * 70, 143 + i * 25, 303 + i * 70, 152 + i * 25, COL_OUTLINE);
// rect(display, 276 + i * 70, 144 + i * 25, 302 + i * 70, 151 + i * 25, COL_LGREY);
rect(display, 276 + i * 70, 141 + i * 25, 302 + i * 70, 152 + i * 25, TRANS_BLUE3);
#define LEVEL_CALC2 (3500 + (1100 * options.stage_power [ship_chosen] [i - 1] [arena.difficulty]))
// duplicated in enemy.c and level.c
wpixels = ((float) (options.stage_power_bar [ship_chosen] [i - 1] [arena.difficulty] * 20) / LEVEL_CALC2);
if (wpixels >= 20 || wpixels < 0)
wpixels = 19;
if (wpixels > 0)
{
rectfill(display, 279 + i * 70, 143 + i * 25, 279 + i * 70 + wpixels, 150 + i * 25, TRANS_RED1);
rect(display, 278 + i * 70, 143 + i * 25, 278 + wpixels + i * 70, 150 + i * 25, TRANS_RED5);
}
END_TRANS
}
//.........这里部分代码省略.........
开发者ID:evktalo,项目名称:butterfly,代码行数:101,代码来源:menu.c
示例8: walk
/* moves a sprite along the spline path */
void walk(void)
{
#define MAX_POINTS 256
int points[8];
int x[MAX_POINTS], y[MAX_POINTS];
int n, i;
int npoints;
int ox, oy;
acquire_screen();
clear_to_color(screen, makecol(255, 255, 255));
for (i=1; i<node_count-1; i++)
draw_node(i);
release_screen();
do {
poll_mouse();
} while (mouse_b);
clear_keybuf();
ox = -16;
oy = -16;
xor_mode(TRUE);
for (n=1; n < node_count-2; n++) {
npoints = (fixtoi(node_dist(nodes[n], nodes[n+1]))+3) / 4;
if (npoints < 1)
npoints = 1;
else if (npoints > MAX_POINTS)
npoints = MAX_POINTS;
get_control_points(nodes[n], nodes[n+1], points);
calc_spline(points, npoints, x, y);
for (i=1; i<npoints; i++) {
vsync();
acquire_screen();
circlefill(screen, ox, oy, 6, palette_color[2]);
circlefill(screen, x[i], y[i], 6, palette_color[2]);
release_screen();
ox = x[i];
oy = y[i];
poll_mouse();
if ((keypressed()) || (mouse_b))
goto getout;
}
}
getout:
xor_mode(FALSE);
do {
poll_mouse();
} while (mouse_b);
clear_keybuf();
}
开发者ID:AntonLanghoff,项目名称:whitecatlib,代码行数:67,代码来源:exspline.c
示例9: start_menu
/*! \brief Main menu screen
*
* This is the main menu... just display the opening and then the menu and
* then wait for input. Also handles loading a saved game, and the config menu.
*
* \param c zero if the splash (the bit with the staff and the eight heroes)
* should be displayed.
* \returns 1 if new game, 0 if continuing, 2 if exit
*/
int start_menu (int skip_splash)
{
int stop = 0, ptr = 0, redraw = 1, a, b;
DATAFILE *bg;
BITMAP *staff, *dudes, *tdudes;
#ifdef DEBUGMODE
if (debugging == 0) {
#endif
play_music ("oxford.s3m", 0);
/* Play splash (with the staff and the heroes in circle */
if (skip_splash == 0) {
bg = load_datafile_object (PCX_DATAFILE, "KQT_PCX");
staff = create_bitmap_ex (8, 72, 226);
dudes = create_bitmap_ex (8, 112, 112);
tdudes = create_bitmap_ex (8, 112, 112);
blit ((BITMAP *) bg->dat, staff, 0, 7, 0, 0, 72, 226);
blit ((BITMAP *) bg->dat, dudes, 80, 0, 0, 0, 112, 112);
clear_bitmap (double_buffer);
blit (staff, double_buffer, 0, 0, 124, 22, 72, 226);
blit2screen (0, 0);
kq_wait (1000);
for (a = 0; a < 42; a++) {
stretch_blit (staff, double_buffer, 0, 0, 72, 226, 124 - (a * 32),
22 - (a * 96), 72 + (a * 64), 226 + (a * 192));
blit2screen (0, 0);
kq_wait (100);
}
for (a = 0; a < 5; a++) {
color_scale (dudes, tdudes, 53 - a, 53 + a);
draw_sprite (double_buffer, tdudes, 106, 64);
blit2screen (0, 0);
kq_wait (100);
}
draw_sprite (double_buffer, dudes, 106, 64);
blit2screen (0, 0);
kq_wait (1000);
destroy_bitmap (staff);
destroy_bitmap (dudes);
destroy_bitmap (tdudes);
unload_datafile_object(bg);
/*
TODO: this fade should actually be to white
if (_color_depth == 8)
fade_from (pal, whp, 1);
else
*/
do_transition (TRANS_FADE_WHITE, 1);
}
clear_to_color (double_buffer, 15);
blit2screen (0, 0);
set_palette (pal);
bg = load_datafile_object (PCX_DATAFILE, "TITLE_PCX");
for (a = 0; a < 16; a++) {
clear_to_color (double_buffer, 15 - a);
masked_blit ((BITMAP *) bg->dat, double_buffer, 0, 0, 0, 60 - (a * 4),
320, 124);
blit2screen (0, 0);
kq_wait (a == 0 ? 500 : 100);
}
if (skip_splash == 0)
kq_wait (500);
#ifdef DEBUGMODE
} else {
set_palette (pal);
bg = load_datafile_object (PCX_DATAFILE, "TITLE_PCX");
}
#endif
reset_world ();
/* Draw menu and handle menu selection */
while (!stop) {
if (redraw) {
clear_bitmap (double_buffer);
masked_blit ((BITMAP *) bg->dat, double_buffer, 0, 0, 0, 0, 320, 124);
menubox (double_buffer, 112, 116, 10, 4, BLUE);
print_font (double_buffer, 128, 124, _("Continue"), FNORMAL);
print_font (double_buffer, 128, 132, _("New Game"), FNORMAL);
print_font (double_buffer, 136, 140, _("Config"), FNORMAL);
print_font (double_buffer, 144, 148, _("Exit"), FNORMAL);
draw_sprite (double_buffer, menuptr, 112, ptr * 8 + 124);
redraw = 0;
}
display_credits ();
blit2screen (0, 0);
readcontrols ();
if (bhelp) {
unpress ();
show_help ();
//.........这里部分代码省略.........
开发者ID:grrk-bzzt,项目名称:kqlives,代码行数:101,代码来源:sgame.c
示例10: loadLvl
int loadLvl(Label cellLabels[], Destination boxes[], BITMAP *&background, int levelNum){
int lbls;
for (int i = 0; i < 20; i++){
cellLabels[i].x = screenw;
cellLabels[i].y = screenh;
cellLabels[i].h = 0;
cellLabels[i].w = 0;
cellLabels[i].clicked = false;
cellLabels[i].visible = false;
boxes[i].x = screenw + 1;
boxes[i].y = screenh + 1;
boxes[i].h = 0;
boxes[i].w = 0;
boxes[i].visible = false;
}
switch(levelNum){
case 1:
lbls = 4;
background = create_bitmap(screenw, screenh);
clear_to_color(background, makecol(125, 38, 205));
for (int i = 0; i < lbls; i++){
cellLabels[i].y = i * 43;
cellLabels[i].x = 735;
cellLabels[i].h = 40;
cellLabels[i].w = 100;
cellLabels[i].clicked = false;
cellLabels[i].visible = true;
boxes[i].x = 0;
boxes[i].y = 225;
if(i >= 6)
boxes[i].y = 500;
boxes[i].h = 40;
boxes[i].w = 100;
boxes[i].visible = true;
}
/*for(int i = 0; i < lbls; i++){
std::swap(cellLabels[i].y, cellLabels[rand()%lbls].y);
}*/
for(int i = 0; i < 4; i++)
boxes[i].x = i * 105 + 4;
for(int i = 6; i < 10; i++)
boxes[i].x = i%6 * 105 + 4;
boxes[4].x = 435;
boxes[5].x = 590;
boxes[10].x = 435;
boxes[11].x = 590;
strcpy(cellLabels[0].name, "A");
strcpy(cellLabels[1].name, "very");
strcpy(cellLabels[2].name, "clean");
strcpy(cellLabels[3].name, "animal");
break;
case 2:
lbls = 5;
background = create_bitmap(screenw, screenh);
clear_to_color(background, makecol(125, 38, 205));
for (int i = 0; i < lbls; i++){
cellLabels[i].y = i * 45 + 214;
cellLabels[i].x = 735;
cellLabels[i].h = 40;
cellLabels[i].w = 100;
cellLabels[i].clicked = false;
cellLabels[i].visible = true;
boxes[i].x = 0;
boxes[i].y = 0;
boxes[i].h = 40;
boxes[i].w = 100;
boxes[i].visible = true;
}
/*for(int i = 0; i < lbls; i++){
std::swap(cellLabels[i].y, cellLabels[rand()%lbls].y);
}*/
boxes[0].x = 33;
boxes[0].y = 362;
boxes[1].x = 256;
boxes[1].y = 440;
boxes[2].x = 476;
boxes[2].y = 315;
strcpy(cellLabels[0].name, "But");
strcpy(cellLabels[1].name, "thought");
strcpy(cellLabels[2].name, "to");
strcpy(cellLabels[3].name, "be");
strcpy(cellLabels[4].name, "dirtiest");
break;
case 3:
lbls = 4;
background = create_bitmap(screenw, screenh);
clear_to_color(background, makecol(125, 38, 205));
for (int i = 0; i < lbls; i++){
cellLabels[i].y = i * 45 + 214;
//.........这里部分代码省略.........
开发者ID:thatdoctorperson,项目名称:bioGame,代码行数:101,代码来源:levels.cpp
示例11: dos_video_init
void dos_video_init(void)
{
/* Change video settings if screen expansion is enabled */
if(option.expand)
{
option.video_driver = GFX_AUTODETECT;
option.video_width = (IS_GG) ? 400 : 512;
option.video_height = (IS_GG) ? 300 : 384;
}
/* Double requested height if scanlines are being used
and screen expansion is disabled */
if((option.scanlines == 1) && (option.expand == 0))
{
option.video_height *= 2;
}
/* Change video settings if tweaked display is enabled */
if(option.tweak)
{
option.video_driver = GFX_VGA;
option.video_depth = 8;
option.video_width = 320;
option.video_height = 200;
}
/* Attempt to set graphics mode */
set_color_depth(option.video_depth);
if(set_gfx_mode(option.video_driver, option.video_width, option.video_height, 0, 0) != 0)
{
printf("Error: %s\n", allegro_error);
exit(1);
}
/* Clear palette and display */
memcpy(sms_pal, black_palette, sizeof(PALETTE));
sms_pal[0xFE].r = sms_pal[0xFE].g = sms_pal[0xFE].b = 0xFF;
set_palette(sms_pal);
clear(screen);
/* Use vertical stretching if screen expansion is enabled,
VGA expansion is disabled, and scanlines are disabled */
if((option.expand == 1) && (option.no_vga == 0) && (option.scanlines == 0))
{
outp(0x3D4, 0x09);
outp(0x3D5, (inp(0x3D5) & 0xE0) | 0x03);
}
/* Force overscan color to be black */
if(option.video_depth == 8)
{
inp(0x3DA);
outp(0x3C0, 0x31);
outp(0x3C0, 0xFF);
clear_to_color(screen, 0xFF);
}
/* Tweak display accordingly */
if(option.tweak)
{
int i, j = IS_GG ? 1 : 0;
/* Disable CRTC write protect */
outp(0x3D4, 0x11);
outp(0x3D5, inp(0x3D5) & 0x7F);
/* Load CRTC parameters */
for(i = 0; i <= 0x0D; i++)
outpw(0x3D4, twktbl[j][i]);
/* Enable CRTC write protect */
outp(0x3D4, 0x11);
outp(0x3D5, inp(0x3D5) | 0x80);
/* Set clocking mode register */
outp(0x3C2, twktbl[j][0x0E]);
/* Set miscellaneous output register */
outpw(0x3C4, twktbl[j][0x0F]);
}
}
开发者ID:frangarcj,项目名称:SMSplusVITA,代码行数:81,代码来源:video.c
示例12: main
int main()
{
int exit_flag = 0, i, j;
MAT16F tmat;
int vnum, node_num;
VERTEX *map_vertex;
STATIC_BSP_NODE *tree;
init();
load_static_bsp("map.bsp", &map_vertex, &vnum, &tree, &node_num);
printf("Vertex Number: %d.\nNode Number: %d.\n", vnum, node_num);
LOCK_VARIABLE(fps);
LOCK_VARIABLE(frame_count);
LOCK_FUNCTION(update_fps);
install_int(update_fps, 1000);
float frame = 0.0;
VEC3F view_volume[5];
VEC3F cam_pos = vec3f(0.0, 3.0, 0.0), cam_dir, cam_dir_normal, cam_ang = vec3f(0.0, 0.0, 0.0);
while(!exit_flag)
{
int mx, my;
get_mouse_mickeys(&mx, &my);
position_mouse(SCREEN_W / 2, SCREEN_H / 2);
cam_ang.x += my * 0.001;
cam_ang.y -= mx * 0.001;
cam_dir.x = CAM_SPEED * cos(0.5 * M_PI + cam_ang.y);
cam_dir.y = CAM_SPEED * cos(0.5 * M_PI + cam_ang.x);
cam_dir.z = CAM_SPEED * sin(0.5 * M_PI + cam_ang.y);
cam_dir_normal = vec3f(-cam_dir.z, 0.0, cam_dir.x);
if(key[KEY_ESC]) {
exit_flag = 1;
}
if(key[KEY_W]) {
cam_pos = VEC3F_SUM(cam_pos, cam_dir);
}
if(key[KEY_S]) {
cam_pos = VEC3F_DIFF(cam_pos, cam_dir);
}
if(key[KEY_A]) {
cam_pos = VEC3F_SUM(cam_pos, cam_dir_normal);
}
if(key[KEY_D]) {
cam_pos = VEC3F_DIFF(cam_pos, cam_dir_normal);
}
set_fov(90.0);
if(mouse_b > 1)
set_fov(30.0);
build_view_volume(view_volume);
reset_mat16f(tmat);
rotate_x_mat16f(tmat, cam_ang.x);
rotate_y_mat16f(tmat, cam_ang.y);
rotate_z_mat16f(tmat, 0.0);
translate_mat16f(tmat, cam_pos.x, cam_pos.y, cam_pos.z);
for(i = 0; i < 5; i++)
transform_vec3f(&view_volume[i], view_volume[i], tmat);
reset_mat16f(tmat);
translate_mat16f(tmat, -cam_pos.x, -cam_pos.y, -cam_pos.z);
rotate_z_mat16f(tmat, 0.0);
rotate_y_mat16f(tmat, -cam_ang.y);
rotate_x_mat16f(tmat, -cam_ang.x);
for(i = 0; i < vnum; i++)
{
transform_vec3f(&map_vertex[i].trans, map_vertex[i].object, tmat);
project_vertex(&map_vertex[i]);
}
for(i = 0; i < node_num; i++)
tree[i].flag = 0;
int checks = 0;
mark_nodes_inside_volume(tree, 0, map_vertex, view_volume, 5, &checks);
int count = 0;
for(i = 0; i < node_num; i++)
if(tree[i].flag == 1)
count++;
clear_to_color(buffer, 0);
clear_to_color(BASE_INT_z_buffer, BASE_INT_z_buffer_precision);
traverse_tree(tree, 0, cam_pos, map_vertex, -1);
textprintf_ex(buffer, font, 10, 10, makecol(255, 255, 255), 0, "FPS: %d", fps);
textprintf_ex(buffer, font, 10, 10, makecol(255, 255, 255), 0, "FPS: %d", fps);
textprintf_ex(buffer, font, 10, 20, makecol(255, 255, 255), 0, "Rendered: %d of nodes, %d of faces.",
(int)((float)checks / (float)node_num * 100.0), (int)((float)count / (float)node_num * 100.0));
//textprintf_ex(buffer, font, 10, 20, makecol(255, 255, 255), 0, "%d", checks);
blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
frame_count++;
//.........这里部分代码省略.........
开发者ID:omer4d,项目名称:SuperOldCode,代码行数:101,代码来源:EX_bsp2.c
示例13: main
int main(void) {
int c; /* character from keyboard */
int i, j, k; /* number of tasks created */
double a; /* temporary variable */
int h; /* temporary variable */
int ntasks = 0; /* total number of created tasks*/
int last_proc = 0; /* last assigned processor */
int max_proc = ptask_getnumcores(); /* max number of procs */
init();
a = 2. * G * (float)TOP;
for (i = 0; i < MAX_TASKS; i++)
v0[i] = sqrt(a);
i = 0;
do {
k = 0;
if (keypressed()) {
c = readkey();
k = c >> 8;
}
if ((ntasks == 0) && (k == KEY_SPACE)) {
clear_to_color(screen, BGC);
rect(screen, XMIN - L - 1, BASE - 1, XMAX + L + 1,
TOP + BASE + L + 1, 14);
}
if ((ntasks < MAX_TASKS) && (k == KEY_SPACE)) {
tpars params = TASK_SPEC_DFL;
params.period = tspec_from(PER, MILLI);
params.rdline = tspec_from(DREL, MILLI);
params.priority = PRIO - i;
params.measure_flag = 1;
params.act_flag = NOW;
/* a round robin assignment */
params.processor = last_proc++;
if (last_proc >= max_proc)
last_proc = 0;
/** i = task_create(palla, PER, DREL, PRIO-i, NOW); */
i = ptask_create_param(palla, ¶ms);
if (i != -1) {
printf("Task %d created and activated\n", i);
ntasks++;
} else {
allegro_exit();
printf("Error in creating task!\n");
exit(-1);
}
}
if ((k >= KEY_0) && (k <= KEY_9)) {
a = 2. * G * (float)TOP;
pthread_mutex_lock(&mxv);
v0[k - KEY_0] = sqrt(a);
pthread_mutex_unlock(&mxv);
}
if ((k == KEY_O) && (ntasks > 9)) {
for (j = 10; j < ntasks; j++) {
h = rand() % (TOP - BASE);
a = 2. * G * (float)h;
pthread_mutex_lock(&mxv);
v0[j] = sqrt(a);
pthread_mutex_unlock(&mxv);
}
}
if (k == KEY_A) {
for (j = 0; j < ntasks; j++) {
h = rand() % (TOP - BASE);
a = 2. * G * (float)h;
pthread_mutex_lock(&mxv);
v0[j] = sqrt(a);
pthread_mutex_unlock(&mxv);
}
}
/*
Printing deadline misses
TO BE DONE
for (j=0; j<ntasks; j++) {
sprintf(s, "%d", task_dmiss(j));
textout_ex(screen, font, s, 50+j*48, 450, 7, 0);
}
*/
} while (k != KEY_ESC);
printf("Now printing the stats\n");
for (j = 0; j < ntasks; j++) {
tspec wcet = ptask_get_wcet(j);
tspec acet = ptask_get_avg(j);
printf("TASK %d: WCET = %ld\t ACET = %ld\t NINST=%d\n", j,
tspec_to(&wcet, MICRO), tspec_to(&acet, MICRO),
ptask_get_numinstances(j));
}
//.........这里部分代码省略.........
开发者ID:glipari,项目名称:ptask,代码行数:101,代码来源:ball.c
示例14: print_grid
void print_grid(int policy, int prot)
{
int i, x, y, k;
int lev;
int at, dl;
char buf[50];
/*------------------------------------------------------*/
/* Draw header */
/*------------------------------------------------------*/
clear_to_color(screen, BGC);
rect(screen, XMIN+30, YMIN+1, XMAX-30, 40, 4);
if (policy == SCHED_FIFO)
sprintf(buf, "TASK schedule produced by SCHED_FIFO");
if (policy == SCHED_RR)
sprintf(buf, "TASK schedule produced by SCHED_RR");
if (policy == SCHED_OTHER)
sprintf(buf, "TASK schedule produced by SCHED_OTHER");
textout_centre_ex(screen, font, buf, 320, 10, 14, 0);
if (prot == PIP) sprintf(buf, "+ PIP");
if (prot == PCP) sprintf(buf, "+ PCP");
if (prot != NOP) textout_centre_ex(screen, font, buf, 488, 10, 14, 0);
textout_centre_ex(screen, font, "(ESC to exit)", 320, 30, 3, 0);
sprintf(buf, "Time scale: %4.1f", scale);
textout_ex(screen, font, buf, XMIN+40, 30, 7, 0);
/*------------------------------------------------------*/
/* Draw grid */
/*------------------------------------------------------*/
for (x=OFFSET; x<XMAX; x+=DXGRID/scale)
for (y=LEV0; y<LEV0+DLEV*(nt-1); y+=DYGRID)
putpixel(screen, x, y, GRIDCOL);
/*------------------------------------------------------*/
/* Draw task timelines */
/*------------------------------------------------------*/
textout_ex(screen, font, "MAIN", 10, LEV0+5, MAINCOL, 0);
line(screen, OFFSET, LEV0, XMAX, LEV0, TLCOL);
line(screen, OFFSET, LEV0, OFFSET, LEV0-10, TLCOL);
for (i=1; i<nt; i++) {
lev = LEV0 + DLEV*i;
at = OFFSET;
sprintf(buf, "T%d", i);
textout_ex(screen, font, buf, 10, lev-8, TLCOL, 0);
line(screen, OFFSET, lev, XMAX, lev, TLCOL);
k = 0;
do {
at = k * period[i];
x = OFFSET + at/scale;
if (x < XMAX) line(screen, x, lev, x, lev-20, TLCOL);
dl = at + dline[i];
x = OFFSET + dl/scale;
if (x < XMAX) {
line(screen, x, lev-1, x, lev-15, DLCOL);
line(screen, x, lev-1, x-1, lev-5, DLCOL);
line(screen, x, lev-1, x+1, lev-5, DLCOL);
}
k++;
} while (x < XMAX);
}
}
开发者ID:JoKeRGreGre,项目名称:PJI,代码行数:73,代码来源:pcp.c
示例15: makecol
void InputDeviceSingleton::BeginJoystickCalibration()
{
int msgColor = makecol(255, 255, 255);
int bgColor = makecol(0, 0, 255);
// for each joystick, run a calibration sequence
for (int index = 0; index < num_joysticks; index++)
{
// clear the screen
clear_to_color(screen, bgColor);
// while the jostick needs to be calibrated
while (joy[index].flags & JOYFLAG_CALIBRATE)
{
// get the calibration message
const char* message = calibrate_joystick_name(index);
// show the message on the screen
textprintf_centre_ex(screen,
font, SCREEN_W / 2, SCREEN_H / 2,
msgColor,
-1,
"%s, and press a key.",
message);
// read a key
readkey();
// try to calibrate the joystick
if (0 != calibrate_joystick(index))
{
// show a message that we failed
textprintf_centre_ex(screen,
font, SCREEN_W / 2, 64 + (SCREEN_H / 2),
msgColor,
-1,
"Could not calibrate the Joystick!");
// read a key
readkey();
// and bail with a fatal error
LogFatal("Could not calibrate the joystick!");
}
}
}
// try to save the calibration data to a file
if (0 != save_joystick_data("joysettings.dat"))
{
// clear the screen to red
clear_to_color(screen, makecol(255, 0, 0));
// show a message on the screen
textprintf_centre_ex(screen,
font, SCREEN_W / 2, SCREEN_H / 2,
makecol(255, 255, 0),
-1,
"Joystick Calibration data file could not be saved! Press a key to exit the program.");
// read a key
readkey();
LogFatal("Joystick Calibration data file could not be saved! Program will now exit!");
}
// clear the screen
clear_to_color(screen, bgColor);
// show a message on the screen
textprintf_centre_ex(screen,
font, SCREEN_W / 2, SCREEN_H / 2,
msgColor,
-1,
"Joysticks have been calibrated. Press a key to exit the program.");
// read a key
readkey();
// log a message that the joysticks were calibrated
LogMessage("Joysticks calibrated! Program Exiting...");
exit(1);
}
开发者ID:RichardMarks,项目名称:48h2009MiniRPGJamEntry,代码行数:82,代码来源:InputDevice_Joystick.cpp
示例16: test_key_map
static void test_key_map(void)
{
int i, k, u;
static int key_was_pressed[KEY_MAX + 1] = {0};
static int key_is_pressed[KEY_MAX + 1] = {0};
static char *welcome[] = {
"Key that is pressed now is marked with red",
"Key that was pressed is marked with yellow",
"Press mouse button or Escape to exit test",
0
};
/* Clear screen and output prompt. */
clear_to_color(screen, white);
for (i = 0; welcome[i] != 0; i++)
textout_ex(screen, font, welcome[i], 8, i * 8 + 8, black, -1);
clear_to_color(screen, white);
for (i = 0; i < KEY_MAX; i++)
textprintf_ex(screen, font, 32 + (i % 4) * 160,
32 + (i / 4) * 14, black, -1, "%s", scancode_to_name (i));
do {
poll_keyboard();
poll_mouse();
}
while ((key[KEY_ESC]) || (mouse_b));
do {
while (keypressed()) {
u = ureadkey (&k);
textprintf_centre_ex (screen, font, SCREEN_W / 2, 8,
red, white, "> %c <", u);
}
poll_keyboard();
poll_mouse();
for (i = 0; i < KEY_MAX; i++) {
if (key[i])
key_was_pressed[i] = key_is_pressed[i] = 1;
else
key_is_pressed[i] = 0;
}
for (i = 0; i < KEY_MAX; i++) {
int x = 16 + (i % 4) * 160;
int y = 32 + (i / 4) * 14;
if (key_is_pressed[i])
rectfill(screen, x, y, x + 7, y + 7, red);
else if (key_was_pressed[i])
rectfill(screen, x, y, x + 7, y + 7, yellow);
else
rectfill(screen, x, y, x + 7, y + 7, white);
}
rest(1);
}
while ((!key[KEY_ESC]) && (!mouse_b));
do {
poll_keyboard();
poll_mouse();
}
while ((key[KEY_ESC]) || (mouse_b));
clear_keybuf();
}
开发者ID:sesc4mt,项目名称:mvcdecoder,代码行数:69,代码来源:xkeymap.c
|
请发表评论