Slowdown... :(

BlitzPlus Forums/BlitzPlus Beginners Area/Slowdown... :(

Buggy(Posted 2006) [#1]
Well, I have a pretty cool game with multiple levels and players and such... without revealing too much before the press release - ;) - I think I can say that it's a top-down spaceship game... aren't they all?

Anyway, the game runs fine for me, except in the rare even that I get some 300 or so homing missiles onscreen at once, but that's expected. Since the homing missiles home in on the player, they often merge with each other. Is there an easy way - I can name a few difficult ones - to delete one of the missiles if it shares it's x, y, and frame with another homing missile?

But there's a more important question I have:

How can I make it so that the entire game doesn't slow down when I create a bullet or delete a player? This is frustrating.

Any help would be extremely appreciated.


Pineapple(Posted 2006) [#2]
I found whilst learning Blitz that For... Each loops can cause a hang... e.g. nesting too many of them!

Without looking at the code to make improvements in it's structure, it's anyones guess!

Dabz


Buggy(Posted 2006) [#3]
Thanks. I realized a big problem. When the game was strictly 1-player, I did something like this:

If player gets hit with the bullet

     draw()
     flip
     delay 1000
     delete player

Endif


I did this so the player could see the bullet actually hit them.

Jeez, I'm stupid.


CS_TBL(Posted 2006) [#4]
Buggy: do you process the game AI and screen-updates according to a timer_event ?


Buggy(Posted 2006) [#5]
I'm not sure what you mean... like this?

If enough time has passed

     Do Stuff()

Endif


If that's the case then I only do that to regulate the player's rotations. Am I in trouble?

I regulate everything with a delaytimer.


CS_TBL(Posted 2006) [#6]
Do you have B+ or B3d ?

If B+:

timer=CreateTimer(30) ; game @ 30fps

Repeat
  WaitEvent()
  If EventID()=$4001 ; iirc, been too much blitzmaxing lately, it should be the timertick-event :P
  ' update game AI
  ' update screen
  Endif
Forever


If you're using polling: you really want to use events instead :P


Buggy(Posted 2006) [#7]
Sorry, but I'm kinda new with all this jargon. I have B3D, but I only learn the terms I need to know at the moment. I have no Idea what polling or events are.


CS_TBL(Posted 2006) [#8]
Ok, if you don't have B+ then forget what I just said.. tho you *might* want to buy B+ and try to start with events.. once you pop you can't stop! ^_^

The difference between polling and events:

With polling there's a mainloop which is processed always. Which kinda hogs the cpu.

With events you work together with the underlaying OS. The only time something happens is when there's an event, for the rest your OS can do its thingies.

Programming with events is: waiting for events and act according to one. It's different compared to polling, but strangely enough I really didn't notice moving from polling to event-based programming when I switched from b3d to B+.


Buggy(Posted 2006) [#9]
Well, now I understand it, though I don't really want to pay any more money...


Grey Alien(Posted 2006) [#10]
If you have B3d why are you posting in the BPlus Forums?


Buggy(Posted 2006) [#11]
Because I make 2D games, and have only seriously been going at it for a few months now... please understand...


CS_TBL(Posted 2006) [#12]
Blitz+ is even faster with 2d compared to B3d..


Buggy(Posted 2006) [#13]
Really?

Is BlitzMax fast? Frankly, I don't want to spend any more money...


Grey Alien(Posted 2006) [#14]
2D games are best in BlitzMax because you can use the 3D card for special effects etc, so yes Max is faster in a way.


CS_TBL(Posted 2006) [#15]
Somehow I think B+ is easier to learn for starters.. must be the excellent B+ manual and the bad BMax manual.


Buggy(Posted 2006) [#16]
I only have B3D and only program 2D games - no 3D effects or anything - and all I know is that the B3D manual isn't too great. I'm a noob, and already I've found poorly documented or non-documented commands. Like ReadLine$(), for instance.