Path: chuka.playstation.co.uk!scea!greg_labrec@interactive.sony.com From: Kevin Newsgroups: scea.yaroze.programming.2d_graphics Subject: multiple sprites -- problem, need help Date: Sat, 26 Jul 1997 09:58:14 -0700 Organization: intuit-10006594!qfn@concentric.net Lines: 197 Message-ID: <33DA2CA6.4A7F@leland.stanford.edu> Reply-To: khauck@leland.stanford.edu NNTP-Posting-Host: sdx-ca16-06.ix.netcom.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.0Gold (Win95; U) I can't seem to get multiple sprites to display. With the code below, all the sprites come out looking like ship2.img. Am I missing something in the definition? It isn't well-written, but I am just trying to get something working so I can make some basic functions I can use all the time. --- BEGIN --- #include #include "ship2.img" #include "ship3.img" #include "ship4.img" #include "ship5.img" ... #define PACKET_CNT 200 ... PACKET GpuPacketArea[2][PACKET_CNT*24]; GsOT world_OT[2]; GsOT_TAG OT_tag[2][1 << 1]; GsSPRITE sprtShip[4]; GsSPRITE *sprtDrawShip; int active_buff; GsLINE line_outer1, line_outer2, line_outer3, line_outer4; #include "sonyintr.c" main () { RECT rect; int i, j = 0, k = 0; int negate_control = 0; int ship_x = 100, ship_y = 100; SetVideoMode (MODE_NTSC); GsInitGraph (320, 240, 4, 0, 0); GsDefDispBuff (0, 0, 0, 240); world_OT[0].length = 1; world_OT[0].org = OT_tag[0]; world_OT[1].length = 1; world_OT[1].org = OT_tag[1]; rect.x = IMG_SHIP2_X; rect.y = IMG_SHIP2_Y; rect.w = IMG_SHIP2_WW; rect.h = IMG_SHIP2_H; LoadImage(&rect, imgShip2); rect.x = IMG_SHIP3_X; rect.y = IMG_SHIP3_Y; rect.w = IMG_SHIP3_WW; rect.h = IMG_SHIP3_H; LoadImage(&rect, imgShip3); rect.x = IMG_SHIP4_X; rect.y = IMG_SHIP4_Y; rect.w = IMG_SHIP4_WW; rect.h = IMG_SHIP4_H; LoadImage(&rect, imgShip4); rect.x = IMG_SHIP5_X; rect.y = IMG_SHIP5_Y; rect.w = IMG_SHIP5_WW; rect.h = IMG_SHIP5_H; LoadImage(&rect, imgShip5); sprtShip[0].tpage = GetTPage(2, 0, IMG_SHIP2_X, IMG_SHIP2_Y); sprtShip[1].tpage = GetTPage(2, 0, IMG_SHIP3_X, IMG_SHIP3_Y); sprtShip[2].tpage = GetTPage(2, 0, IMG_SHIP4_X, IMG_SHIP4_Y); sprtShip[3].tpage = GetTPage(2, 0, IMG_SHIP5_X, IMG_SHIP5_Y); sprtShip[0].attribute = IMG_SHIP2_ATTR; sprtShip[1].attribute = IMG_SHIP3_ATTR; sprtShip[2].attribute = IMG_SHIP4_ATTR; sprtShip[3].attribute = IMG_SHIP5_ATTR; for (i = 0; i < 4; i++) { sprtShip[i].x = 100; sprtShip[i].y = 100; sprtShip[i].w = 9; sprtShip[i].h = 9; sprtShip[i].u = 0; sprtShip[i].v = 0; sprtShip[i].r = 128; sprtShip[i].g = 128; sprtShip[i].b = 128; sprtShip[i].mx = 5; sprtShip[i].my = 5; sprtShip[i].scalex = ONE; sprtShip[i].scaley = ONE; sprtShip[i].rotate = 0; } sprtDrawShip = &sprtShip[1]; ... { u_long old_state; u_long cont_state; GsBOXF box1, box2; GetPadBuf (&bb0, &bb1); while (1) { cont_state = PadRead(1); if (cont_state & PAD_SELECT) break; if (negate_control > 0) negate_control--; else { if (cont_state & PAD_LEFT) { if (ship_x > 10) ship_x -= GAME_SHIP_STEP; negate_control = GAME_CONTROL_DELAY; sprtDrawShip = &sprtShip[0]; } else if (cont_state & PAD_RIGHT) { if (ship_x < 300) ship_x += GAME_SHIP_STEP; negate_control = GAME_CONTROL_DELAY; sprtDrawShip = &sprtShip[1]; } else if (cont_state & PAD_UP) { if (ship_y > 10) ship_y -= GAME_SHIP_STEP; negate_control = GAME_CONTROL_DELAY; sprtDrawShip = &sprtShip[2]; } else if (cont_state & PAD_DOWN) { if (ship_y < 220) ship_y += GAME_SHIP_STEP; negate_control = GAME_CONTROL_DELAY; sprtDrawShip = &sprtShip[3]; } } // init graphics, get ready to draw active_buff = GsGetActiveBuff(); GsSetWorkBase((PACKET *)GpuPacketArea[active_buff]); GsClearOt(0, 0, &world_OT[active_buff]); // optional // drawing code goes here GsSortLine (&line_outer1, &world_OT[active_buff], 1); GsSortLine (&line_outer2, &world_OT[active_buff], 1); GsSortLine (&line_outer3, &world_OT[active_buff], 1); GsSortLine (&line_outer4, &world_OT[active_buff], 1); sprtShip[0].x = 100; sprtShip[0].y = 20; sprtShip[1].x = 120; sprtShip[1].y = 20; sprtShip[2].x = 140; sprtShip[2].y = 20; sprtShip[3].x = 160; sprtShip[3].y = 20; GsSortFastSprite (&sprtShip[0], &world_OT[active_buff], 1); GsSortFastSprite (&sprtShip[1], &world_OT[active_buff], 1); GsSortFastSprite (&sprtShip[2], &world_OT[active_buff], 1); GsSortFastSprite (&sprtShip[3], &world_OT[active_buff], 1); sprtDrawShip->x = ship_x; sprtDrawShip->y = ship_y; GsSortFastSprite(sprtDrawShip, &world_OT[active_buff], 1); // finish drawing DrawSync(0); GsSwapDispBuff(); GsSortClear(0, 0, 0, &world_OT[active_buff]); GsDrawOt(&world_OT[active_buff]); } /* while */ } return (0); } --- END --- sprtShip[0, 1, 2, 3] is supposed to show up depending on which direction the ship is heading. But only sprtShip[0] shows up, no matter which direction the control is pressed. Also the four ships at the top center of the screen all look the same, when they should be different. I checked the .img files to make sure they are different and they are, and they defined as SHIP2 (x, y): 320, 0 SHIP3 (x, y): 330, 0 SHIP4 (x, y): 340, 0 SHIP5 (x, y): 350, 0 in the .img file. Please help if you can, thanks- --- Dan