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 / massive problem

Author
Message
kirtn14
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 11th Feb 2012 12:43
the piece of coding im wrighting doesnt work


its suppost to move all sprites exclueding 7,15 to 28, 35,49 and 63 but it moves them back aswell and i keep loking at the code and i cant see why it b ecause i havnt spesified them to be moved ive writen this about 348 times for each sprite and its just so anoying when it wont work

kirtnicholls
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 11th Feb 2012 21:29 Edited at: 11th Feb 2012 21:45
Depends where you are positioning those sprites for one. But in the code above I can only see the one sprite (21) being moved? Are you moving the viewport to view that sprite? If so it would appear move all of the sprites when sprite 21 is moved to originalx#, originaly#.

Edit - you may want to make a typed array for the sprites to make your code more efficient. For instance make a type called something descriptive, say, spritedata. Add something like hit_type in the type. Dim an array called sprites[numberofsprites] as spritedata. Make a loop to run through all your 70 sprites in one go. Set the data in the loop for hit_type, so in a for next loop, sprites[n].hit_type=1. Then you can put in a bit of code to change the ones you want to be avoided back to 0. Then you can alter your code above to one single loop and check if the sprite is available by checking the array sprite[spritenumber].hit_type and checking for 1.
You could add in a string to read in the hit_type data as well, so you can put the correct data in the original loop rather than redoing afterwards. But one thing at a time, the lack of a data command means you have to use string$ for this sort of thing, which is a little more awkward than nice data statements.

Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 11th Feb 2012 23:42
The problem may not lie that the piece of code you have posted. We'll need to see a bit more.

kirtn14
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 12th Feb 2012 14:03
this is all the code, its massive, i know that doesnt work because when i press sprite 7 it wont move no matter what the sprite is



kirtnicholls
kirtn14
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 12th Feb 2012 15:27
Basicly this code should provent you from
Moving the wrong sprite, it's like tw game solitare if you put a 6 on a 8 the 6 moves back and If 8 is put in a 6 then the 8 is moved back that's Basicly what I'm
Trying to achieve

kirtnicholls
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 16th Feb 2012 04:13
Yikes! Theres a lot of uneeded repeated code there, for instance.

Why are you going through so many loops? This continues on and on and all seems to be identical code. I think it would be faster to go through one loop for all of them, then just set the odd ones you want left out for some reason I can't fathom, back to 0 or whatever is needed.
I'll have a look tomorrow when I have more time. Just thought I'd ask about the need to miss out certain sprites from your loop list? Wouldn't it be better to have one loop for tiles and another for the missing numbers?

kirtn14
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 16th Feb 2012 08:44
Yey are all nesisary, I have 5 types of sprite and 14 sprites of each type making 70 sprites
Sprite 1 can collide with all sprites up to 14 and all sprite 1's from the othe types 15, 29,43,57 and this is the same for each sprite they cancolide with there own sprite type and identical sprites from other types if you get me that's why all the same code, it's to prevent the wrong sprite being moved

kirtnicholls
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 18th Feb 2012 10:33
Just add the sprites into collision groups, so some sprites cannot collide with others and use the physics collision.

My signature is NOT a moderator plaything! Stop changing it!
kirtn14
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 18th Feb 2012 12:22
Could you please give me an example?

kirtnicholls

Login to post a reply

Server time is: 2024-11-26 20:58:36
Your offset time is: 2024-11-26 20:58:36