プレイ日記
Kl'Dck Hul HissingToaster
Callbacks? In my BASIC?! I manage all sprite collision through a single object operating on plain arrays. When two things touch, their "onHit" method is called. Anything not actively being controlled by a player or AI doesn't require an update! THE SAVINGS!!!
4そうだね
プレイ済み
返信[1]
親投稿
Kl'Dck Hul HissingToaster
Peeps might recognize this technique from all my physics demos. The difference this time is that behaviors are coupled to sprites - physics calls SPOFS directly. This is in contrast to each entity polling physics for a position in an update method.
1そうだね
プレイ済み
返信[2]
親投稿
raimondz raimondzz
A problem that I see with the code is that only the first collision will be detected(From my experience if 3 sprites overlap, then SPHITSP will return the sprite with the lowest management number.) For example, for sprites with management number 1,2,3, the collision detected would be (1,2), (2,1) and (3,1). To solve that problem you need to use a loop to call SPHITSP() without arguments.
0そうだね
プレイ済み
返信[3]
親投稿
raimondz raimondzz
Example: SP%=_.SP%[I%] IF SP%>-1 THEN HIT%=SPHITSP(SP%) WHILE 1 IF HIT%==-1 THEN BREAK ...'Code inside IF HIT%>-1 THEN HIT%=SPHITSP() WEND ENDIF
1そうだね
プレイ済み
返信[4]
親投稿
Kl'Dck Hul HissingToaster
@Raimondz: I was aware that could happen, but I didn't realize I could just keep calling SPHIT(). By post-poning collision until all sprites are resolved, I at least guarantee some hit happens to each. What I'm curious about is how I would manage the memory around multiple hits. Each call to 'Hit.bind' allocates memory for one collision. How many collisions do I really need to preallocate?
0そうだね
プレイ済み