Mercurial > hg > Members > kono > tree_dandy2
view Character_state.c @ 21:b7654db65a34
add TODO
author | koba <koba@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 10 Dec 2010 19:04:17 +0900 |
parents | 01387a2e419e |
children | 3b92a4b17049 |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <SDL.h> #include "SDL_opengl.h" #include "object.h" #include "Character.h" #include "Character_state.h" #include "count2.h" #include "schedule.h" #include "bom.h" #include "sankaku.h" #include "sgoex.h" #include "collision.h" #include "debug.h" #include "tama.h" CHARACTER *kyeenemyno; CHARACTER *tekino0; CHARACTER *enemy_part1; CHARACTER *enemy_part2; CHARACTER *enemy_part3; CHARACTER *enemy_part4; CHARACTER *enemy_part5; //int tekino0; int rinkx; int rinky; int rinkf1 = 0, rinkf2 = 0; CHARACTER *asteroiddt[200]; int asteroidi = 0; int enemyfaste = 0; int sf; int amari; int fastebos = 0; CHARACTER * noaction(CHARACTER *p) { p->state = noaction; return p; } CHARACTER * chara_state0(CHARACTER *p) { p->x += p->vx; p->y += p->vy; p->state = chara_state0; //PutSprite(count, p->x, p->y, p->charano); return p; } CHARACTER * chara_state1(CHARACTER *p) { p->x -= p->vx; p->y -= p->vy; p->state = chara_state1; //PutSprite(count, p->x, p->y, p->charano); return p; } CHARACTER * chara_state2(CHARACTER *p) { p->vy -= 0.25; p->y += p->vy; p->state = chara_state2; //PutSprite(count, p->x, p->y, p->charano); return p; } CHARACTER * chara_state3(CHARACTER *p) { p->x += p->vx; p->y += p->vy; if((p->dt1 == 60) || (p->dt1 == 90) || (p->dt1 == 30)) { Puttama(0, p->x, p->y); } p->dt1++; p->state = chara_state3; //PutSprite(count, p->x, p->y, p->charano); return p; } CHARACTER * chara_state4(CHARACTER *p) { p->y += p->vy; p->x += p->vx; if(p->y < jiki.y && p->y + 16 > jiki.y) { p->vy = -2; p->vx = ((jiki.x > p->x) ? 4 : -4); p->state = chara_state7; } else p->state = chara_state4; //PutSprite(count, p->x, p->y, p->charano); return p; } CHARACTER * chara_state5(CHARACTER *p) { p->y += p->vy; p->x += p->vx; if(p->y + 96 < jiki.y && p->y + 128 > jiki.y) { p->vy = -2; p->vx = ((jiki.x > p->x) ? 4 : -4); p->state = chara_state0; } else p->state = chara_state5; //PutSprite(count, p->x, p->y, p->charano); return p; } CHARACTER * chara_state6(CHARACTER *p) { p->y += p->vy; p->x += p->vx; if(p->y + 96 < jiki.y && p->y + 128 > jiki.y) { p->vy = 2; p->vx = ((jiki.x > p->x) ? 4 : -4); p->state = chara_state0; } else p->state = chara_state6; //PutSprite(count, p->x, p->y, p->charano); return p; } CHARACTER * chara_state7(CHARACTER *p) { p->x += p->vx; p->y += p->vy; if((p->dt1 == 60) || (p->dt1 == 90) || (p->dt1 == 30)) { Puttama(1, p->x, p->y); } p->dt1++; p->state = chara_state7; //PutSprite(count, p->x, p->y, p->charano); return p; } // state1 boss patern CHARACTER * chara_state8(CHARACTER *p) { if(p->y < 520) { tekino0 = p; kyeenemyno = p; p->y += p->vy; count++; DefSpriteEx(p->charano, 16*4, 32*4); PutSpriteEx(p->charano, (p->x * 4), (p->y * 4), 0.2, 0.2, 1); p->dt1 = 512; p->s = 0.125; p->state = chara_state8; return p; } p->state = chara_state9; return p; } CHARACTER * chara_state9(CHARACTER *p) { if(p->s <= 2) { p->s += 0.05; p->y -= 12; count++; DefSpriteEx(54, 16*4, 32*4); PutSpriteEx(54, (p->x * 4), (p->y * 4), p->s, p->s, 1); p->state = chara_state9; return p; } count++; DefSpriteEx(54, 16, 32); PutSpriteEx(54, p->x, p->y, p->s, p->s, 1); rinkx = p->x; rinky = p->y; Putenemy(5, rinkx - 16, rinky - 16, 1, 0, chara_state10); Putenemy(5, rinkx - 16, rinky - 16, -1, 0, chara_state10); p->state = chara_state11; p->dt1 = 8192; return p; } CHARACTER * chara_state10(CHARACTER *p) { if(p->dt1 < 48) { p->x += p->vx; p->y += p->vy; p->dt1++; p->state = chara_state10; //PutSprite(count, p->x, p->y, return p; } rinkf1 = 1; p->dt1 = rinkx; p->dt2 = rinky; p->state = chara_state13; return p; } CHARACTER * chara_state11(CHARACTER *p) { if(rinkf1 == 0) { count++; DefSpriteEx(54, 16, 32); PutSpriteEx(54, p->x, p->y, p->s, p->s, 1); p->state = chara_state11; return p; } p->dt1 = 0; p->dt2 = 0; p->state = chara_state12; return p; } CHARACTER * chara_state12(CHARACTER *p) { if(fastebos > 60*60) { if(p->y > 240+32) { p->state = delete_chara; } p->y += 3; rinky += 3; count++; DefSpriteEx(54, 16, 32); PutSpriteEx(54, p->x, p->y, 2, 2, 1); p->state = chara_state12; return p; } if(p->dt1 <= 60) { if(jiki.x + 15 - rinkx < -5) { p->vx = -0.8; } else if(jiki.x + 15 - rinkx > 5) { p->vx = +0.8; } else p->vx = 0; rinkx = p->x; rinky = p->y; } if((p->dt1 > 60) && (p->dt1 <= 70)) { if(p->dt1 % 2 == 1) { Puttama(0, rinkx - 16, rinky); Puttama(0, rinkx, rinky); Puttama(0, rinkx + 16, rinky); } } if((p->dt1 > 180) && (p->dt1 <= 240)) { if(p->dt1 % 2 == 1) { rinkf2 = 1; Puttama(2, rinkx - 16, p->y - 32); Puttama(3, rinkx + 32 - 16, p->y - 32); } else { rinkf2 = 2; } } if(p->dt1 > 240) { rinkf2 = 2; } if((p->dt1 > 240) && (p->dt1 <= 400)) { count++; PutSprite(count, rinkx - 16, rinky + 32, 58 + p->dt1 % 4); } if((p->dt1 > 300) && (p->dt1 <= 400)) { rinkf2 = 3; if(jiki.x + 15 - rinkx < -5) { p->vx = -1; } else if(jiki.x + 15 - rinkx > 5) { p->vx = +1; } else p->vx = 0; p->x += p->vx; rinkx = p->x; rinky = p->y; Puttama(4, rinkx - 8, rinky + 16); } if((p->dt1 > 400) && (p->dt1 <= 500)) { rinkf2 = 4; if(jiki.x + 15 - rinkx > 5) { p->vx = -1; } else if(jiki.x + 15 - rinkx > 5) { p->vx = +1; } else p->vx = 0; p->x += p->vx; rinkx = p->x; rinky = p->y; } if(p->dt1 > 500) { rinkf2 = 5; if(jiki.x + 15 - rinkx < -5) { p->vx = -1; } else if(jiki.x + 15 - rinkx > 5) { p->vx = +1; } else p->vx = 0; p->x += p->vx; rinkx = p->x; rinky = p->y; } if(p->dt1 > 600) { rinkf2 = 0; p->dt1 = 0; } fastebos++; p->dt1++; count++; DefSpriteEx(54, 16, 32); PutSpriteEx(54, p->x, p->y, 2, 2, 1); return p; } CHARACTER * chara_state13(CHARACTER *p) { if(tekino0->f == FALSE){ Bom(p->x, p->y); p->f = FALSE; p->state = delete_chara; p->collision = noaction; return p; } p->x += rinkx - p->dt1; p->y += rinky - p->dt2; p->dt1 = rinkx; p->dt2 = rinky; if(rinkf2 == 1) { if(p->x > rinkx) { Puttama(2, p->x + 32, p->y); } if(p->x < rinkx) { Puttama(3, p->x, p->y); } } if(rinkf2 == 4) { count++; PutSprite(count, p->x, p->y + 56, 58+filpcount % 4); } if(rinkf2 == 5) { if(p->x > rinkx) { Puttama(5, p->x + 8, p->y + 24); } if(p->x < rinkx) { Puttama(5, p->x + 8, p->y + 24); } } return p; } CHARACTER * chara_state20(CHARACTER *p) { p->x += p->vx; p->y += p->vy; p->vy -= 0.5; p->vy += 0.4; return p; } CHARACTER * chara_state21(CHARACTER *p) { p->x += p->vx; p->y += p->vy; p->vx += 0.5; p->vy += 0.4; return p; } //ここまでgetate boss CHARACTER * chara_state22(CHARACTER *p) { sf = rand() % 4; if((sf == 0) || (sf == 1)) { p->x = -35; p->y = rand() % (120 - 35); p->vx = (rand() % 4 + 1); p->vy = rand() % 3 + 1; p->state = chara_state23; } if((sf == 2)) { p->x = rand() % 290; p->y = -30; p->vx = rand() % 3 - 1; p->vy = (rand() % 4 + 1); p->state = chara_state23; } if(sf == 3) { p->x = 320; p->y = rand() % (120 - 35); p->vx = (rand() % 4 + 1) * -1; p->vy = rand() % 3 -1; p->state = chara_state23; } return p; } CHARACTER * chara_state23(CHARACTER *p) { p=asteroid(p); return p; } CHARACTER * chara_state24(CHARACTER *p) { kyeenemyno = p; tekino0 = 0; enemy_part1 = p->next; enemy_part2 = enemy_part1->next; enemy_part3 = enemy_part2->next; enemy_part4 = enemy_part3->next; enemy_part5 = enemy_part4->next; rinkx = 0; rinky = 0; rinkf1 = 0; rinkf2 = 0; p->state = chara_state25; return p; } CHARACTER * chara_state25(CHARACTER *p) { if(p->dt1 <= 360) { p->x = Mycos(p->dt1) * 30 / SANKAKU + 82 + 32; p->y = Mysin(p->dt1) * 30 / SANKAKU + 30; } if(p->dt1 > 360) { p->x = Mycos(p->dt1) * 30 * -1 /SANKAKU + 142 + 32; p->y = Mysin(p->dt1) * 30 / SANKAKU + 30; } count++; PutSprite(count, p->x - 42, p->y, 64); amari = rand() % 160; if((amari == 1) && (enemy_part5->f == TRUE)) { p->state = chara_state26; rinkf1 = 1; } if((amari == 2) && (enemy_part1->f == TRUE)) { p->state = chara_state27; rinkf1 = 5; rinkx = 0; return p; } if((enemy_part5->f == TRUE) && (enemy_part1->f != TRUE)) { p->state = chara_state28; } p->dt1 += 3; if(p->dt1 == 720) { p->dt1 = 0; } return p; } CHARACTER * chara_state26(CHARACTER *p) { if((p->dt2 > 50) && (p->dt2 < 100)) { rinkf1 = 2; } if(p->dt2 > 100) { rinkf1 = 3; } if(p->dt2 == 400) { rinkf1 = 4; } count++; PutSprite(count, p->x - 42, p->y, 64); if(p->dt2 == 401) { p->dt2 = 0; rinkf1 = 0; p->state = chara_state25; return p; } p->dt2++; return p; } CHARACTER * chara_state27(CHARACTER *p) //rocket punch { if((p->dt2 > 50) && (p->dt2 < 60) && (p->x > -24) && (p->y > -24)) { rinkf1 = 6; rinkx -= 4; p->x -= 4; p->y -= 4; } if(p->dt2 == 80) { rinkf1 = 7; } if(p->dt2 == 81) { rinkf1 = 8; } if(p->dt2 == 124) { rinkf1 = 9; } if(p->dt2 == 400) { rinkf1 = 10; } if(p->dt2 == 444) { rinkf1 = 11; } if(p->dt2 == 500) { rinkf1 = 12; } if((p->dt2 > 80) && (p->dt2 < 200)) { if((rinkx != 0) && (p->dt2 % 2 == 1)) { rinkx++; p->x++; p->y++; } } count++; PutSprite(count, p->x - 32, p->y, 6); if(rinkf1 == 12) { p->dt2 = 0; rinkf1 = 0; rinkx = 0; p->state = chara_state25; return p; } p->dt2++; return p; } CHARACTER * chara_state28(CHARACTER *p) { if (p->dt1 <= 360) { p->x = Mycos(p->dt1) * 30 / SANKAKU + 82 + 32; p->y = Mysin(p->dt1) * 30 / SANKAKU + 30; } if (p->dt1 > 360) { p->x = Mycos(p->dt1) * 30 * -1 / SANKAKU + 142 + 32; p->y = Mysin(p->dt1) * 30 / SANKAKU + 30; } count++; PutSprite(count, p->x - 42, p->y, 64); if (p->dt1 % 30 == 3) { Putenemy(24, p->x + 14, p->y + 14, (rand() % 5 + 0.5) * (rand() % 2 == 1 ? -1 : 1), (rand() % 5 + 0.5) * (rand() % 2 == 1 ? -1 : 1), chara_state29); } p->dt1 += 3; return p; } CHARACTER * chara_state29(CHARACTER *p) { p->x += p->vx; p->y += p->vy; if(p->dt1 % 18 == 1) { Puttama(0, p->x, p->y); } p->dt1++; return p; } CHARACTER * chara_state30(CHARACTER *p) { p->x = p->x - 32; p->y = p->y; return p; } CHARACTER * chara_state31(CHARACTER *p) //right hand { if((enemy_part3->f == FALSE) || (kyeenemyno->f == FALSE)) { Bom(p->x, p->y); p->f = FALSE; p->state = delete_chara; p->collision = noaction; return p; } if(rinkf1 == 0) { p->x = kyeenemyno->x + 40; p->y = kyeenemyno->y + 28; p->dt2 = 0; } if(rinkf1 == 5) { p->x = kyeenemyno->x + 52; p->y = kyeenemyno->y; count++; PutSprite(count, p->x - 4, p->y - 20, 80 + p->dt2 % 4); p->dt2++; } if(rinkf1 == 6) { if(p->y < 240 - 40) { p->y += 6; } else { return p; } count++; PutSprite(count, p->x - 4, p->y - 20, 90 + p->dt2 % 4); p->dt2++; } if(rinkf1 == 7) { Putenemy(22, p->x + 14, p->y + 14, 0, 0, chara_state40); return p; } if(rinkf1 == 11) { if(p->y + 20 != p->y) { p->y--; } else { return p; } count++; PutSprite(count, p->x + 8, p->y + 44, 58 + p->dt2 % 4); p->dt2++; } return p; } CHARACTER * chara_state32(CHARACTER *p) //left hand { if ((enemy_part4->f == FALSE) || (kyeenemyno->f == FALSE)) { Bom(p->x, p->y); p->f = FALSE; p->state = delete_chara; p->collision = noaction; return p; } p->x = kyeenemyno->x - 40; p->y = kyeenemyno->y + 28; if (rinkf1 == 5) { p->x = kyeenemyno->x - 24 + 4; p->y = kyeenemyno->y + 28; p->charano = enemystate[20].charano; } if (rinkf1 == 11) { p->charano = enemystate[14].charano; } if (rinkf1 == 7) { Putenemy(23, p->x + 14, p->y + 14, 0, 0, chara_state41); // rinkf1=8; return p; } return p; } CHARACTER * chara_state33(CHARACTER *p) // right shoulder { if (kyeenemyno->f == FALSE) { Bom(p->x, p->y); p->f = FALSE; p->state = delete_chara; p->collision = noaction; return p; } p->x = kyeenemyno->x + 32; p->y = kyeenemyno->y; if (rinkf1 == 5) { p->x = kyeenemyno->x + 32 - 4; p->y = kyeenemyno->y; p->charano = enemystate[19].charano; } if (rinkf1 == 6) { p->charano = enemystate[11].charano; } return p; } CHARACTER * chara_state34(CHARACTER *p) //left shoulder { if (kyeenemyno->f == FALSE) { Bom(p->x, p->y); p->f = FALSE; p->state = delete_chara; p->collision = noaction; return p; } p->x = kyeenemyno->x - 32; p->y = kyeenemyno->y; if (rinkf1 == 5) { p->charano = enemystate[21].charano; } if (rinkf1 == 6) { p->charano = enemystate[12].charano; } return p; } CHARACTER * chara_state35(CHARACTER *p) // bust { if (kyeenemyno->f == FALSE) { Bom(p->x, p->y); p->f = FALSE; p->state = delete_chara; p->collision = noaction; return p; } p->x = kyeenemyno->x; p->y = kyeenemyno->y + 32; if (rinkf1 == 1) { p->charano = enemystate[16].charano; } if (rinkf1 == 2) { count++; PutSprite(count, p->x - 10, p->y + 16, 58 + p->dt2 % 4); count++; PutSprite(count, p->x + 10, p->y + 16, 58 + p->dt2 % 4); p->dt2++; } if (rinkf1 == 3) { count++; PutSprite(count, p->x - 10, p->y + 16, 58 + p->dt2 % 4); count++; PutSprite(count, p->x + 10, p->y + 16, 58 + p->dt2 % 4); if (p->dt2 % 20 == 1) { Puttama(7, p->x, p->y + 16); Puttama(7, p->x + 20, p->y + 16); } p->dt2++; } if (rinkf1 == 4) { p->charano = enemystate[15].charano; p->dt2 = 0; } return p; } CHARACTER * chara_state40(CHARACTER *p) //arm vulkan { if (enemy_part1->f == FALSE) { Bom(p->x, p->y); p->f = FALSE; p->state = delete_chara; p->collision = noaction; return p; } if ((rinkf1 == 8) && (p->dt1 % 3 == 1)) { if ((p->dt2 < 16)) { p->dt2++; DefSprite(76, "boss2_rightarm_b", 16, p->dt2, 480, boss); } else { // rinkf1=9; return p; } } if (rinkf1 == 9) { if (p->dt1 % 15 == 1) { Puttama(8, p->x, p->y); } } if (rinkf1 == 10) { if (p->dt2 != 0) { p->dt2--; DefSprite(76, "boss2_rightarm_b", 16, p->dt2, 480, boss); } else { p->f = FALSE; p->state = delete_chara; p->collision = noaction; // rinkf1=11; } } p->dt1++; return p; } CHARACTER * chara_state41(CHARACTER *p) //left arm up arm vulkan { if (enemy_part2->f == FALSE) { Bom(p->x, p->y); p->f = FALSE; p->state = delete_chara; p->collision = noaction; return p; } p->x = kyeenemyno->x - 20 - 7; p->y = kyeenemyno->y + 28 + 15; if ((rinkf1 == 8) && (p->dt1 % 3 == 1)) { if ((p->dt2 < 16)) { p->dt2++; DefSprite(77, "boss2_leftarmbattery", p->dt2, 16, 480, boss); /*左腕アップアーム砲 */ } else { rinkf1 = 9; return p; } } if (rinkf1 == 9) { if (p->dt1 % 15 == 1) { Puttama(9 + rand() % 2, p->x, p->y); } } if (rinkf1 == 10) { if (p->dt2 != 0) { p->dt2--; DefSprite(77, "boss2_leftarmbattery", p->dt2, 16, 480, boss); } else { p->f = FALSE; p->state = delete_chara; p->collision = noaction; return p; // rinkf1=11; } } p->dt1++; return p; } CHARACTER * chara_state400(CHARACTER *p) { p->vy++; p->y += p->vy / 4; p->state = chara_state400; return p; } CHARACTER * chara_state401(CHARACTER *p) { p->vx++; p->x += p->vx / 8; if (p->x > (jiki.x - 32)) { p->vy--; } p->y += p->vy / 8; if (p->dt1 % 50 == 37) { Puttama(1, p->x + 8, p->y + 24); } p->dt1++; return p; } CHARACTER * chara_state402(CHARACTER *p) { p->vx--; p->x += p->vx / 8; if (p->x < (jiki.x + 32)) { p->vy--; } p->y += p->vy / 8; if (p->dt1 % 50 == 37) { Puttama(1, p->x + 8, p->y + 24); } p->dt1++; return p; } CHARACTER * chara_state410(CHARACTER *p) { kyeenemyno = p; p->state = chara_state411; return p; } CHARACTER * chara_state411(CHARACTER *p) { if (p->dt2 > 356) { p->vx = -1; } if (p->dt2 < -398) { p->vx = 1; } if ((p->dt1) % 62 == 0) Putenemy(41, p->x, p->y, (int) -Mycos(p->dt1 / 16) * 4 / SANKAKU, (int) -Mysin(p->dt1 / 16) * 4 / SANKAKU, chara_state7); if ((p->dt1) % 13 == 0) Puttama(11, p->x + 32, p->y + 32); p->dt2 += p->vx; p->dt1 += p->dt2 / 4; p->x = jiki.x - 16 + Mycos(p->dt1 / 16) * 128 / SANKAKU; p->y = jiki.y - 16 + Mysin(p->dt1 / 16) * 128 / SANKAKU; if (p->x < 0) { p->x = 0; } if (p->x > 260) { p->x = 260; } if (p->y < 0) { p->y = 0; } if (p->y > 232) { p->y = 232; } return p; } CHARACTER * chara_state500(CHARACTER *p) { p->s = 0; kyeenemyno = p; p->dt2++; p->dt2 %= 512; p->dt1++; count++; DefSpriteEx(100, 16, 16); // PutSprite(count, enemy[tekino].x + 16, // enemy[tekino].y + 16, 100); PutSpriteEx(100, p->x + 16, p->y + 16, 2, 2, p->dt1); if (p->dt1 % (5 + p->dt2 / 8) == 1) { if (rand() % 2 == 1) Putenemy(24, p->x, p->y, (rand() % 5 + 0.5) * (rand() % 2 == 1 ? -1 : 1), (rand() % 5 + 0.5) * (rand() % 2 == 1 ? -1 : 1), chara_state501); else Putenemy(rand() % 2 + 1, p->x, p->y, (int) Mycos(p->dt1 / 4) * 4 / SANKAKU, (int) -Mysin(p->dt1 / 4) * 4 / SANKAKU, chara_state501); } if (p->dt1 == 50) { /*Putenemy(44,0,0,1,1,411); */ } return p; } CHARACTER * chara_state501(CHARACTER *p) { p->x += p->vx; p->y += p->vy; if(p->dt1 % 32 == 1) { Puttama(11, p->x, p->y); } p->dt1++; return p; } CHARACTER * chara_state600(CHARACTER *p) { kyeenemyno = p; p->dt1 += 30; p->dt2++; p->dt1 %= 360; p->x += Mycos(p->dt1) * 4 / SANKAKU; p->y += Mysin(p->dt1) * 4 / SANKAKU; Puttama(11, p->x + 16, p->y + 16); Puttama(11, p->x + 32, p->y + 48); Puttama(11, p->x + 48, p->y + 16); if (p->dt2 > 240) p->state = chara_state601; if (p->x < 0) p->x = 0; if (p->x > 260) p->x = 260; if (p->y < 0) p->y = 0; if (p->y > 232) p->y = 232; return p; } CHARACTER * chara_state601(CHARACTER *p) { p->dt2++; if (p->x < jiki.x) p->vx++; if (p->x > jiki.x) p->vx--; p->x += p->vx; Putenemy(6, p->x + 16 + rand() % 32, p->y, 0, rand() % 4, chara_state400); if (p->x < 0) p->x = 0; if (p->x > 260) p->x = 260; if (p->y < 0) p->y = 0; if (p->y > 232) p->y = 232; if (p->dt2 > 800) { p->state = chara_state602; } return p; } CHARACTER * chara_state602(CHARACTER *p) { p->dt2++; Putenemy(24, p->x + 14, p->y + 14, (rand() % 5 + 0.5) * (rand() % 2 == 1 ? -1 : 1), (rand() % 5 + 0.5) * (rand() % 2 == 1 ? -1 : 1), chara_state29); if (p->dt2 > 1024) { p->state = chara_state600; p->dt2 = 0; } return p; } CHARACTER * asteroid(CHARACTER *p) { int i; asteroiddt[asteroidi] = p; // if(asteroidi==0) // { p->x += p->vx; p->y += p->vy; // } if (asteroidi > 0) { for (i = 0; i < asteroidi; i++) { if ((asteroiddt[i]->x + 32 > p->x) && (p->x + 32 > asteroiddt[i]->x) && (asteroiddt[i]->y + 32 > p->y) && (asteroiddt[i]->y < p->y + 32)) { p->vx *= -1; p->vy *= -1; } } } asteroidi++; return p; }