管理人さんこの前はありがとうございました。
しかし時たま出てくる謎の線がどうしても気になるので、再度質問させてください。
その謎の線がでる状態と同じプログラムを作ってみました。
皆さん、わかる方がいましたらどうぞよろしくお願いします。
Windows XP Home Edition Service Pack 3
Intel(R) Core(TM)2 Quad CPU Q8200 @ 2.33GHz (4 CPUs)
DirectX 9.0c (4.09.0000.0904)
NVIDIA GeForce 9600 GT
VC++2005
#include "DxLib.h"
#include <time.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.1415926535897932384626433832795
#define RAD 57.295779513082320876798154814105
bool WindowMode = TRUE;
LONGLONG timer;
int i;
int count=0;
float plx=320,ply=400;
int T1[6];
#include "enemy_shot.h"
int X;
int rnd(int min, int max){
int aaa = 0;
aaa = (rand() % (max - min + 1)) + min;
return(aaa);
}
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow ){
SetGraphMode( 640 , 480 , 16 );
ChangeWindowMode( WindowMode );
if( DxLib_Init() == -1 ) return -1;
SetDrawScreen( DX_SCREEN_BACK );
srand(time(NULL));
SetTransColor( 255,0,255 );
LoadImg();
while(1){
ClearDrawScreen();
timer = GetNowHiPerformanceCount() ;
AddEShot2(ABS,X,rnd(0,200), rnd(1,3),rnd(0,360),T1[BLUE]);
AddEShot2(ABS,X,rnd(0,200), rnd(1,3),rnd(0,360),T1[BLUE]);
AddEShot2(ABS,X,rnd(0,200), rnd(1,3),rnd(0,360),T1[BLUE]);
AddEShot2(ABS,X,rnd(0,200), rnd(1,3),rnd(0,360),T1[BLUE]);
X+=3;
if(X>640){
for(i=0; i<ESHOT2MAX; i++)
eshot2s[i].used = false;
X=0;
}
DrawEShot();
ActionEShot();
ScreenFlip();
while( GetNowHiPerformanceCount() - timer < 16666 );
if( ProcessMessage() == -1 ) break;
}
DxLib_End();
return 0;
}
/////////////////////////////////////////
enemy_shot.h
#define ESHOT2MAX 4096
#define RED 0
#define GREEN 1
#define BLUE 2
#define YELLOW 3
#define CYAN 4
#define MAGE 5
#define PLAYER 0
#define ABS 1
void LoadImg();
void DrawEShot();
void ActionEShot();
void AddEShot2(int TYPE, int X, int Y, float SP, float ANGLE, int IMG);
void DrawEShot2();
void ActionEShot2();
struct Eshot2{
int type;
float x,y,vx,vy;
float angle;
float sp;
int img;
bool used;
};
Eshot2 eshot2s[ESHOT2MAX];
void LoadImg(){
LoadDivGraph( "image/etama_1.png" , 6 , 6 , 1 , 8 , 8 , T1 );
}
void DrawEShot(){
DrawEShot2();
}
void ActionEShot(){
ActionEShot2();
}
void AddEShot2(int TYPE, int X, int Y, float SP, float ANGLE, int IMG){
for(i=0; i<ESHOT2MAX; i++){
if(eshot2s[i].used == false){
eshot2s[i].type = TYPE;
eshot2s[i].x = X;
eshot2s[i].y = Y;
eshot2s[i].angle = ANGLE/RAD;
eshot2s[i].sp = SP;
if(eshot2s[i].type == ABS){
eshot2s[i].vx = cos(ANGLE/RAD)*eshot2s[i].sp;
eshot2s[i].vy = sin(ANGLE/RAD)*eshot2s[i].sp;
} else if(eshot2s[i].type == PLAYER){
if(eshot2s[i].x < plx){
eshot2s[i].angle = atan( (eshot2s[i].y - ply)/(eshot2s[i].x - plx)) + ANGLE/RAD;
eshot2s[i].vx = cos(eshot2s[i].angle)*SP;
eshot2s[i].vy = sin(eshot2s[i].angle)*SP;
} else if(eshot2s[i].x > plx){
eshot2s[i].angle = atan( (eshot2s[i].y - ply)/(eshot2s[i].x - plx)) + ANGLE/RAD;
eshot2s[i].vx = -cos(eshot2s[i].angle)*SP;
eshot2s[i].vy = -sin(eshot2s[i].angle)*SP;
} else {
eshot2s[i].angle = atan( (eshot2s[i].y - ply)/(eshot2s[i].x - plx)) + ANGLE/RAD;
eshot2s[i].vx = cos(eshot2s[i].angle)*SP;
eshot2s[i].vy = -sin(eshot2s[i].angle)*SP;
}
}
eshot2s[i].img = IMG;
eshot2s[i].used = true;
break;
}
}
}
void DrawEShot2(){
for(i=0; i<ESHOT2MAX; i++){
if(eshot2s[i].used == true){
DrawRotaGraph( eshot2s[i].x, eshot2s[i].y, 1.0f, 0, eshot2s[i].img, TRUE ) ;
}
}
}
void ActionEShot2(){
for(i=0; i<ESHOT2MAX; i++){
if(eshot2s[i].used == true){
eshot2s[i].x += eshot2s[i].vx*0.5;
eshot2s[i].y += eshot2s[i].vy*0.5;
if(eshot2s[i].x < -64 || eshot2s[i].x > 640+64 || eshot2s[i].y < -64 || eshot2s[i].y > 480+64)eshot2s[i].used = false;
}
}
}