How to run two loops at once?
Root / Programming Questions / [.]
Jbomb6Created:
Since I'm not the best at programming I've been just making games that don't really have a premise. One of these games right now I just call space. In it your a little space man flying around and there is this black hole slowly getting bigger and bigger. Once you touch it you die, eventually I want to turn it into more but that's all I have made so far. But anyway so the guy will move I made a loop and so the black hole will get bigger I made another loop too. But the thing is I can't have those going at once without adding something extra, I don't know that that extra is. I tried combining the loops but that won't work so if someone could help me it would be much appreciated.
I tried combining the loops but that won't workYou mean, you tried combining the loops but the way you tried didn't work. What did you do, that didn't work? In what way didn't it work?
Late response but you could put the loops in DEFs and call them in a single loop.
VAR S: VAR HIT: VAR B:VAR X=150:VAR Y=100 SPSET 0,'SpaceMan sprite SPSET 1,'Blackhole Sprite SPOFS 0,X,Y:SPOFS 1,150,0:SPCOL 0 WHILE 1 INC S,0.2 SpaceMan Blackhole IF HIT==TRUE THEN BREAK VSYNC WEND END DEF SpaceMan B=BUTTON() IF B AND #UP THEN DEC Y IF B AND #RIGHT THEN INC X IF B AND #DOWN THEN INC Y IF B AND #LEFT THEN DEC X SPOFS 0,X,Y END DEF Blackhole HIT=SPHITSP(1) SPCOL 1,TRUE: SPSCALE 1,S,S ENDNote: I didn't test this but it should be a simple way of achieving what you want.
Honestly, for something that's always going to be a circle, wouldn't a simple radius check be more advised? Edit: Now that I think about it, wouldn't GCIRCLE be better than scaling a sprite?Late response but you could put the loops in DEFs and call them in a single loop.The SPCOL for the black hole needs to have scale adjustment enabled....Note: I didn't test this but it should be a simple way of achieving what you want.
Idk, I figured scaling a sprite is easy to comprehend so I went with that option. Also, not noted in the code but if going with the scaling sprite option, I would recommend using SPHOME to center the point of collision (or wherever it needs to be)Honestly, for something that's always going to be a circle, wouldn't a simple radius check be more advised? Edit: Now that I think about it, wouldn't GCIRCLE be better than scaling a sprite?Late response but you could put the loops in DEFs and call them in a single loop.The SPCOL for the black hole needs to have scale adjustment enabled....Note: I didn't test this but it should be a simple way of achieving what you want.
Ah, that would make sense, but I'm not entirely certain either. I'll test it out later.