Показать сообщение отдельно
Старый 05.12.2013, 14:59   #1
YoLo
AnyKey`щик
 
Аватар для YoLo
 
Регистрация: 05.12.2013
Сообщений: 2
Написано 0 полезных сообщений
(для 0 пользователей)
Проблемка!

Ну вообщем дела обстоят так:
Я недавно начал учиться программировать и столкнулся с проблемкой.
Вроде все правильно картинка то поворачивается, но поворачивается неправильно, хотя угол указываю тот же. Вот листинг:
SuperStrict

Global playerImage:TImage=LoadAnimImage("D:/project/media/pics/exp1.png",64,64,0,15) 
MidHandleImage playerImage 
Global missleImage:TImage=LoadImage("D:/project/media/pics/missle.png")
MidHandleImage missleImage
Global LMissle:TList = New TList 

Type TMissle "Тип ракет"
Field x:Float
Field y:Float
Field angel:Float
Field speed:Float
Field image:TImage 

Method Update()

x=x+(speed*Cos(angel))
y=y+(speed*Sin(angel))

SetRotation angel  " угол поворота (тот же, что и у игрока)
DrawImage missleimage,x,y

End Method

Function createMissle:TMissle(xs:Float,ys:Float,angels:Float,speeds:Float,images:TImage)
 Local missle:TMissle = New TMissle
  missle.x = xs
  missle.y = ys
  missle.angel = angels
  missle.speed = speeds
  missle.image = images
  ListAddLast(LMissle,missle)
End Function 

End Type 

Type Tplayer "Тип игрока"

Field x:Float
Field y:Float
Field frame:Int
Field angel:Float
Field speed:Float
Field animnext:Float
Field image:TImage 

Method Update()
 
 Local xc:Float
 Local yc:Float
 xc =x "Проверочные координаты"
 yc = y

 x=x+(KeyDown(KEY_D)-KeyDown(KEY_A))*speed  "Проверка на движение" 
 y=y+(KeyDown(KEY_S)-KeyDown(KEY_W))*speed

 If KeyHit(KEY_SPACE) Then "Проверка на стрельбу"
  TMissle.createMissle(x,y,angel,10,missleImage) "Указан угол поворота игрока относительно мышки"
 End If 

 If animnext<MilliSecs() Then "Перелистовка кадров"
   animnext=MilliSecs()+50 
   frame:+1
 End If


  angel=angelFunc(x,y,MouseX(),MouseY()) "Обозначение AngelFunc ниже"
 If frame=8 Then frame=0 

 If x = xc And y = yc Then
  My_DrawAnimImage(x,y,angel,0,image)
 ElseIf x < xc Or x > xc Or y < yc Or y > yc Then "Прорисовка игрока"
  My_DrawAnimImage(x,y,angel,frame,image)
 End If 

End Method 

Function createPlayer:Tplayer(xs:Float,ys:Float,frames:Int,angels:Float,speeds:Float,animnexts:Float,images:TImage)
 Local pl:Tplayer = New Tplayer
  pl.x = xs
  pl.y = ys
  pl.frame = frames
  pl.angel = angels
  pl.speed = speeds
  pl.animnext = animnexts
  pl.image = images
  Return pl
End Function 

End Type 

Function My_DrawAnimImage(x:Float,y:Float,angel:Float,frame:Int,image:TImage)
  SetRotation angel
  DrawImage image,x,y,frame
End Function 

Function angelFunc:Float(x1:Float,y1:Float,x2:Float,y2:Float) "Вычисление угла"
 Return ATan2(y2-y1,x2-x1)
End Function 

Global player:Tplayer = Tplayer.createPlayer(100,100,0,0,3.5,0,playerImage)

Graphics 1024,780
Repeat
Cls

player.update()
For Local s:TMissle=EachIn LMissle
 s.update
Next 

Flip
Until KeyHit(KEY_ESCAPE)
End
Укажите пожалуйста на ошибку.
(Offline)
 
Ответить с цитированием