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.

AppGameKit Classic Chat / more problems with editor

Author
Message
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 11th Feb 2013 10:54 Edited at: 11th Feb 2013 12:23
well, after thinking everything was ok i added the ability to delete sprites in the editor, i decided on having a 'deletedsprites[]' array to store those deleted, so that if the user wants to place another it first checks if any are available in the deleted 'bank' before adding a totally new one...



Sounds simple and kinda works, but when it comes to saving and reloading the level, it refuses to edit the loaded sprites and only edits any new ones placed after loading, must be my code but no idea where! anyhow I have included the full project if anyone can be bothered.. thanks in advance for any help!


**edit ***

if you add this to the main loop

place a single brick anywhere...
you will see the values are fine, without loading you are able to edit/delete this sprite, after you save and load though, even though the values are still ok when loaded, i cannot edit/delete it and indeed i have a message saying it has deleted sprite number 0!

Hail to the king, baby!

Attachments

Login to view attachments
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 11th Feb 2013 17:01
It sounds like you have a counter when placing tiles down. When you place your original bricks and edit all works fine. If you tried to load a level without resetting your counter, it could cause this sort of problem. Of course you may not use one at all and just rely on an x,y array. However, I am not downloading the entire project to scour and check I'm afraid. Hopefully my original guess is somewhere near the mark. Editors can seem like a simple thing to start on, but can quickly become almost as complicated as the games they are designed to aid.

It may be a problem with auto generated id's also, as that can cause this sort of thing as well. Once an id has been assigned, even after deleting, it will never be used again by AGK. Any sprite made using say, sprite=(createsprite(0)) will never go back to it's original ID, unless you save that ID in your array and use it when reloading. Automatic ID's start from 10000 and count up. As far as I know there is no way to reset this in AppGameKit to reset back down to 10000 again while running your app. So check the sprite number is what you expect it to be on reloading. The get sprite hit command is good for checking this.

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 11th Feb 2013 17:03
why you want recycle sprites?

delete is the same as set a new one,
you can use it also to create the new sprite to free the block before.

delete
if brick[x].spritenumber
deletesprite(brick[x].spritenumber)
brick[x].spritenumber=0
endif

overwrite
if brick[x].spritenumber then deletesprite(brick[x].spritenumber)
brick[x].spritenumber =createsprite(...)
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 11th Feb 2013 22:42
they aren't automatic I'D's,it simply starts as sprite #1 and increments,so next sprite is #2 and so forth,as far as i know i reset all counters and stuff used in a clear_level() function,coz they are not automatically signed an ID i have to make sure i don't use the same sprite twice,hence the recycling bit,least that is what was my thinking

Hail to the king, baby!
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 11th Feb 2013 23:37
i don't like the fixed id's.
you can use something like this.

before
global pointer = 900

fix for your project
global pointer = GetNextID()

brick[x].spritenumber =GetNextID()
createsprite(brick[x].spritenumber)
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 12th Feb 2013 12:42 Edited at: 12th Feb 2013 12:50
Editors are always a good idea, irrelevant of how hard they could be, the game is practically wrote just with the editor itself as most functions you simply paste across! I will try your way markus.. i am just a bit peeved that you get a choice of fixed or automatic but the former has a problem...I simply am dleteing all sprites and remaking them on load, i dont get hopw the values in the array could be wrong when the loading heavily relies on them being right and they do indeed load correctly in the correct place with the correct image!

the reset routine is this:




the load function this:






and the save:






on the user pressing the load button it calls the clear_level() function then calls the load_level_function, save button simply calls the save_level()

So to me it shouldnt have a problem..yet it has!!



anyhow thanks for the help

Hail to the king, baby!
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 12th Feb 2013 13:06 Edited at: 12th Feb 2013 13:15
your editor is very easy but i would do it a bit different because experience. english is not my native language.
what i will say i can't write because for one german word i have 10 in english.

if you want i would rework your code for you.
If so, append the last Editor Code.

my suggestions:

writeinteger (myfile,brickcount)
for n = 1 to brickcount
writeinteger (myfile,brick[n].x)
writeinteger (myfile,brick[n].y)
writeinteger (myfile,brick[n].imagetyp)
next n

-----------------

brickcount = readinteger (myfile)
for n = 1 to brickcount
brick[n].x = readinteger (myfile)
brick[n].y = readinteger (myfile)
brick[n].imagetype = readinteger (myfile)

select brick[n].imagetype
case 1
img=imgblockred
endcase
case 2
img=imgblockblue
endcase
endselect
brick[n].sprid=createsprite (img) //or GetNextID()
SetSpriteGroup ( brick[n].sprid,2)
setspritesize(brick[n].sprid,swidth,sheight) //why not saved with and height?
setspriteposition(brick[n].sprid,brick[n].x,brick[n].y)
endif
next n
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 12th Feb 2013 13:53 Edited at: 12th Feb 2013 13:54
tried your code,it still isnt deleting the loaded sprites, i have included the projects folder if you are interested.

Hail to the king, baby!

Attachments

Login to view attachments
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 12th Feb 2013 14:04
it has gotten real messy,i have no idea now how i would even place a new brick with this new system. looks like a rewrite really

Hail to the king, baby!
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 12th Feb 2013 14:17 Edited at: 12th Feb 2013 14:29
ah never mind..damnit! I realised at some point i had changed the spritehitgroup number at some point in all but one place! from now on i will use vars for everything,my whole original system works now..thanks for your help still though, and sorry for time wasting

Hail to the king, baby!
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 12th Feb 2013 14:36
not a whole rewrite, just copy/paste and some changes by intuition.
i am not at home but i do this today.
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 12th Feb 2013 14:56
it is ok, all works fine now,I just missed changing one single value, but an important one setting the SetSpriteGroup,it totally explains why they were not deleting as they were loading with the wrong group number! I still have a bad habit of sometimes using numerics instead of vars, and when i read books like hands on agk I sometimes see this bad habit in even them books also,here and there!

Hail to the king, baby!
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 12th Feb 2013 15:00
on another note,while this post is still active, is there any way that i dont yet know of, of how to make AppGameKit NOT exit on the top part of screen being pressed running on the tablets runner, it is abit annoying when i am testing such things as a level editor on it!

Hail to the king, baby!
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 12th Feb 2013 16:41
The back button on android is accessed with scancode 27 I believe. So you may be able to do something with that. I'm not sure about other buttons though such as home. There may be a way to ignore them, but not that I know of.

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 12th Feb 2013 17:58
I believe a real app made with the interpreter core don't exit.
its only a emergency exit in this agk player.
or paint your bricks only < 5 seconds.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 12th Feb 2013 21:23
shadey, please use the Edit button on your posts rather than making multiple posts unless someone else has already responded. Thank you!


this.mess = abs(sin(times#))
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 12th Feb 2013 22:11
here is your editor back.

Attachments

Login to view attachments
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 13th Feb 2013 11:31
yeh ok baxslash, no problem! this forum is too important for me to even think of disobeying! thanks again for the help markus, i have now moved swiftly on to using the editor and got some project running which loads levels created with the editor, so all is good... I am on a kinda curfew or whatever the saying but as soon as my kids get home from school at 3:20pm, i get booted off the pc for the rest of the day, as we only have 1 pc and I have 6 kids! I just like to get problems sorted out before i even forget what the problem was the next day! friggin kids!

Hail to the king, baby!

Login to post a reply

Server time is: 2024-05-07 12:02:59
Your offset time is: 2024-05-07 12:02:59