Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Late collision and sometimes no collision
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Newguy




PostPosted: Thu May 01, 2008 7:29 pm   Post subject: Late collision and sometimes no collision

Ok in my game I have they guy shooting and moving fine and it can also shoot stuff but the enemies die after the bullet moves through them and sometimes they don't die at all. I have no idea why this is happening. Help me figure out what is wrong. Thanks for any help.


Game.rar
 Description:
Game

Download
 Filename:  Game.rar
 Filesize:  6.62 KB
 Downloaded:  84 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
The_Bean




PostPosted: Thu May 01, 2008 8:00 pm   Post subject: Re: Late collision and sometimes no collision

What version of turing are you using.
On mine you can't use gif's.
I managed to change them to jpg but only the enemies showed up flying across the screen, with no character or bullets.
Newguy




PostPosted: Thu May 01, 2008 8:24 pm   Post subject: Re: Late collision and sometimes no collision

The latest version of Turing. You can find it on holtsoft.com I believe. Look at my attachment if you are having problems with .gifs
The_Bean




PostPosted: Thu May 01, 2008 9:13 pm   Post subject: Re: Late collision and sometimes no collision

thats why i didn't get 4.1.1 a , but now that i have it i might have figured out whats going on.

why do u have XCT and enemy_x

Turing:

    for Index : 1 .. enemies
        randint (enemy_x (Index), 1, maxx)
        randint (enemy_y (Index), maxy - 200, maxy)
        XCT (Index) := enemy_x (Index)
    end for

your defining the x and y positions of the enemies and then making XCT and enemy_x = each other.

Turing:

for Index : 1 .. enemies
            XCT (Index) := XCT (Index) - enemy_speed   %XCT is equal to itself minus the speed because their moving left makes sense
            drawfilloval (XCT (Index) div 1, enemy_y (Index), 10, 10, 1)
            drawoval (XCT (Index) div 1, enemy_y (Index), 11, 11, red)
            drawfilloval ((XCT (Index) - 5) div 1, enemy_y (Index) + 5, 3, 3, red)
            drawfilloval ((XCT (Index) + 5) div 1, enemy_y (Index) + 5, 3, 3, red)  % all of the drawing is with XCT
            drawarc (XCT (Index) div 1, enemy_y (Index), 5, 5, 180, 0, white)
            drawarc (XCT (Index) div 1, enemy_y (Index), 6, 6, 180, 0, white)
            if XCT (Index) + 50 < 1 then % if the enemy is to close to edge of screen they reset
                randint (enemy_x (Index), maxx + 50, maxx + 100)
                randint (enemy_y (Index), 10, maxy)
                XCT (Index) := enemy_x (Index)
            end if
            %Collision with bullet
            if Length (bulletx, bullety, enemy_x (Index), enemy_y (Index)) < 10 then % this might be the problem, you've done everything with XCT, changing its value then drawing it
                                                                                     % but your checking the distance with the old value of it
                randint (enemy_x (Index), maxx + 50, maxx + 100)
                randint (enemy_y (Index), 10, maxy)
                XCT (Index) := enemy_x (Index)
                score += 1
            end if
            if enemy_x (Index) + 30 < 1 then % not sure if this is needed because it is already being changed above but with XCT
                randint (enemy_x (Index), maxx, maxx + 20)
                randint (enemy_y (Index), 60, maxy - 60)
            end if
        end for


it might make things alot easier if you were to just use one or the other, not XCT and enemy_x
Newguy




PostPosted: Sat May 03, 2008 3:20 pm   Post subject: Re: Late collision and sometimes no collision

The_Bean @ Thu May 01, 2008 9:13 pm wrote:
thats why i didn't get 4.1.1 a , but now that i have it i might have figured out whats going on.

why do u have XCT and enemy_x

Turing:

    for Index : 1 .. enemies
        randint (enemy_x (Index), 1, maxx)
        randint (enemy_y (Index), maxy - 200, maxy)
        XCT (Index) := enemy_x (Index)
    end for

your defining the x and y positions of the enemies and then making XCT and enemy_x = each other.

Turing:

for Index : 1 .. enemies
            XCT (Index) := XCT (Index) - enemy_speed   %XCT is equal to itself minus the speed because their moving left makes sense
            drawfilloval (XCT (Index) div 1, enemy_y (Index), 10, 10, 1)
            drawoval (XCT (Index) div 1, enemy_y (Index), 11, 11, red)
            drawfilloval ((XCT (Index) - 5) div 1, enemy_y (Index) + 5, 3, 3, red)
            drawfilloval ((XCT (Index) + 5) div 1, enemy_y (Index) + 5, 3, 3, red)  % all of the drawing is with XCT
            drawarc (XCT (Index) div 1, enemy_y (Index), 5, 5, 180, 0, white)
            drawarc (XCT (Index) div 1, enemy_y (Index), 6, 6, 180, 0, white)
            if XCT (Index) + 50 < 1 then % if the enemy is to close to edge of screen they reset
                randint (enemy_x (Index), maxx + 50, maxx + 100)
                randint (enemy_y (Index), 10, maxy)
                XCT (Index) := enemy_x (Index)
            end if
            %Collision with bullet
            if Length (bulletx, bullety, enemy_x (Index), enemy_y (Index)) < 10 then % this might be the problem, you've done everything with XCT, changing its value then drawing it
                                                                                     % but your checking the distance with the old value of it
                randint (enemy_x (Index), maxx + 50, maxx + 100)
                randint (enemy_y (Index), 10, maxy)
                XCT (Index) := enemy_x (Index)
                score += 1
            end if
            if enemy_x (Index) + 30 < 1 then % not sure if this is needed because it is already being changed above but with XCT
                randint (enemy_x (Index), maxx, maxx + 20)
                randint (enemy_y (Index), 60, maxy - 60)
            end if
        end for


it might make things alot easier if you were to just use one or the other, not XCT and enemy_x


Thanks for the help. Yeah I made XCT = enemy_x because I wanted real numbers for the enemy speed but no matter. Speed 1 is fine.

So I took out all the extra code that you told me to and now if it collides with the enemy the enemy dies. But the delayed death still occurs. So after it is past the enemy, the enemy dies. If you want a look at the changed code than I attached it below. Thanks for your help. Smile



Game.rar
 Description:

Download
 Filename:  Game.rar
 Filesize:  10.36 KB
 Downloaded:  87 Time(s)

Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: