View Single Post
Old 09 June 2018, 18:52   #48
Master484
Registered User
 
Master484's Avatar
 
Join Date: Nov 2015
Location: Vaasa, Finland
Posts: 525
One thing that you could try is to use normal variables instead of variables that are inside of lists, arrays or NEWTYPE lists.

Variables that look like "enemy()\x" are super slow. And I think the same goes for the array variables in this code piece you posted:

Code:
for f =0 to num_enemies
   for g = 0 to num_bullets
       if enemyx(f) > bulletx(g) - 8
          if enemyx(f) < bulletx(g) + 8
              if enemyy(f) > bullety(g) - 8
                 if enemyy(f) < bullety(g) + 8
                          collide()
                 endif
              endif
          endif
        endif
    next
next
So to make this faster, you might try a version that looks something like this:

Code:
for f =0 to num_enemies
   for g = 0 to num_bullets

       ex = enemyx(f) ; makes normal variables
       bx = bulletx(g)

       if ex > bx - 8
          if ex < bx + 8

              ey = enemyy(f)  ; makes normal variables
              by = bullety(g)

              if ey > by - 8
                 if ey < by + 8
                          collide()
                 endif
              endif
          endif
        endif
    next
next
So you just first place the "list variables" into normal word variables, and then do all the checks with the normal variables.

And you should do the same thing for all parts of the code that make operations with variables that are inside lists/arrays/NewTypes and so on.

Every time when Blitz sees something like "enemyX (item number)", it first goes through a process where it searches for that variable inside that array/list/NEWTYPE list or whatever. And this is very slow.

---

Also here is a small shooter demo that I made last year:
http://eab.abime.net/showthread.php?t=85844

The ADF called "AGADualPlayfieldShmup" has a "bullet hell" style demo, although it's A1200 only...I can't remember much of it, but I think the collision detection was quite fast and it has blitz source code in the disk.
Master484 is offline  
 
Page generated in 0.05776 seconds with 11 queries