Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 18th May 2010 16:37
Hi all,

I\'m working on a 2D scrolling shooter, and everything is working fine, however, when the player runs out of credits and doesn\'t hit continue before 10 seconds runs out, I need the game to restart.

Currently I\'m executing a function that deletes all loaded images, all sprites, sounds, music, etc, etc and re-sets all variables back to their default value. Then I flush the video memory and jump back to the start of the program (yes, with a GOTO command. I know, I know) and let the whole program load over again.

However, when I do that, while the game DOES work fine in terms of re-loading the images and re-creating the sprites, all of the sprites now leave trails behind them as they move, creating an awful mess on the screen. I have pixelated streaks running everywhere! I can\'t really post the code as you\'d need the dozens of assets I\'m using, not to mention that the code itself is 1400 lines long at the moment...

Am I missing something here? I kind of wish there was a command that would just reset the entire program as if someone had closed it and run it again, but I can\'t seem to find one...

Any hints? Tips? Advice?
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 18th May 2010 20:47
A screen shot or video would be nice. Sounds maybe like a double buffering problem. The background isn't being redrawn and the sprite is leaving a picture of itself as you move it. If you use paste sprite and are updating the background manually rather than just sprite, it may be a problem with your screen selection.
As to the reseting of stuff. Is there any real need to delete all your objects and recreate them? If they do not change from game to game why not just leave them in memory and just reuse them? Just hide them for the main menu and show them when the game starts. The only thing that will affect your restart is the variables and such, the images can be left alone.
Other than that make sure you have all your stats printing up so that you can see them. Create a little routine to slow the game down either frame by frame or just really slow when you hit a button. Then run it, and hit the slow button just before you end the first level. Then check they are as they should be, on the restart.

http://s6.bitefight.org/c.php?uid=103081
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 19th May 2010 03:44
I'll try and whip up a screenshot later tonight, but you're exactly right. The background isn't being redrawn and the sprites are leaving pictures of themselves as they move.

I'm needing to delete the sprites as they are being generated by the engine (not always the same number of sprites on the screen. They are created and deleted as the game is played)
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 19th May 2010 04:18
Hi, when you create a sprite use the set sprite command after you create a sprite and set the flags to their according values. I'm not on my usual computer so I can't post any code but look up set sprite in the help files. There's a flag for backsaving (streaking)

If it hasn't exploded yet, I haven't touched it.
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 19th May 2010 08:10
I can understand that something along those lines would be required, but I don't know why it would suddenly start doing it to all my sprites when nothing has been changed regarding the creation of sprites...
Brendy boy
21
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 19th May 2010 21:58
when you jump to the start of the program call BACKDROP ON command, maybe that will help

"After you finish the first 90% of a project, you have to finish the other 90%." - Michael Abrash
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 20th May 2010 03:12
Thanks Brendy Boy, I'll try that when I get home later, though I don't know why the background would have suddenly been set to off when I never told it to. Nothing environmentally has changed other than the sprites being deleted and recreated.

Anyway, here's that screenshot I promised:
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 20th May 2010 19:00
Are you using just plain old sprite 1,x,y,image? Or are you pasting them down and copying and redrawing the the background manually using multiple screens?
Also when you reset all your images, sprites and variables are you using the same code as used at the start of the game? Or are you running more code to do it? If you are doubling your code, then try to get all your sprite setup and variable setup together(you probably have already), and put it just before your game start. Then just send it back to that code. All you need to add at the start of the setup code is if the sprites exist, delete them.
It may not help but it should eliminate the possiblity that you have missed something out in your exit game code.
Backdrop on could well sort it out if you have not set it at all.
Oh another thing, still see no need to delete the images, even if you are making sprites on the fly. I'm sure you can just load images back over the old ones if you want. The sprites maybe...

http://s6.bitefight.org/c.php?uid=103081

Login to post a reply

Server time is: 2026-07-25 16:21:51
Your offset time is: 2026-07-25 16:21:51