Results 1 to 10 of 31

Thread: Dynamic in-game object creation and manipulation

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    The player's bullets starts from right place, but the enemy's bullets sometimes comes from wrong places, as you can see in my program which can be download from 20th post.

  2. #2
    It's over 800 lines of code and not in english so it's difficult to read.

    Here is something odd:
    Code:
    function TFoablak.pontirany(x1,y1,x2,y2: integer): word;
    var szam: integer;
    begin
        szam:=round(arctan2(y2-y1,x2-x1));
        if szam<0 then
                szam:=round(szam+2*pi);
        pontirany:=round(360-(szam*180)/pi);
    end;
    You should set szam: single; instead of integer, and not round it directly from arctan2(). There is too much precision lost for angle (if you have radians as integer there are only about 6 different angles in the whole 360 range.).

    Also
    Code:
    if numofbullets>0 then  // < This line is not needed.
      begin
        i:=0;
        while i<numofbullets-1 do
    Lets see what happens if numofbullets = 0:
    Code:
    i:=0;
        while 0<-1 do
    0 is not < -1 so it never enters the while.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •