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 / Help! Sprite does not want to enter from off the map.

Author
Message
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 23rd Mar 2012 03:34
Im sure my math was fine and the numbers seem to move correctly and wonder if this may even be a bug of some sort.

Im trying to make an intro where my character is dropped off at a helicopter pad and it seems that my chopper will not start off of the screen. It stays in the center of the screen at an edge of the random map untill the math catches up to its location and then starts moving to the pad as the screen follows.

This is very odd so i even tried making it so my screen position could move past the map and pass off to other vars so the screen would not go past the edge and the chopper still stays in the center untill the math catches up and then moves the chopper to the pad with the screen following.

Im realy scratching my head on this one.

Source code included can somebody take a look and see if they can figure it out?

Mabey i missed something but i was sure this code should work.

Worst case scenareo i guess i will just code the helicopter flying into the screen by screen position and then let it take over from there.

But if you can spot a math error let me know...or if you have a better way to do this.

Give the program a few seconds for the math to center in the screen before the helicopter moves to the pad....

Suppose to enter the map from far off it but doesnt....

Attachments

Login to view attachments
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 23rd Mar 2012 03:41
Here is a screen shot

Attachments

Login to view attachments
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 23rd Mar 2012 03:59 Edited at: 23rd Mar 2012 04:02


oddly i commented the restrictions out....
then changed this as well



i added the code to just exit the function if the restrictions were passed and it works fine....

but when i put the restrictions in the chopper stays on the screen......some bizaar thing is going on here cause this should just work.....im aiming towards bug... or im realy missing some goofy thing i've coded in here.

here is the source with those 2 things changed and look....

btw(those vars are globals and not the problem)

Any thoughts?

Attachments

Login to view attachments
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 23rd Mar 2012 04:16 Edited at: 23rd Mar 2012 04:20
...original message removed....

however i am noticing the fps speed will not stay consistant but may just be my pc?

Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 23rd Mar 2012 12:43 Edited at: 23rd Mar 2012 12:47
Try doing this...



I suspect your little man is stopping on the top wall...

EDIT: Probably should have read all your post before offering a suggestion. This may have nothing to do with your issue... My bad...
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 23rd Mar 2012 15:01
thats ok...

any thoughts on whats wrong with my code is much apreciated.


you must admit though that its very strange that the sprite starts in the center of the map on the first example. but on the second with the restrictions off shows the chopper starting off map as i suspected it would.

SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 24th Mar 2012 18:47
any body got any ideas?

Well im gunna use my second code then and allow my array to go out of bounds as that seems to be the quickest fix....this way i can get focused back on the main project.


Thanks anyways

SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 24th Mar 2012 19:25 Edited at: 24th Mar 2012 19:26
ok now im pissed....lol well not realy but then i discovered this command

Quote: "SetViewOffset( x, y ) "


I did not know you can change the view port x,y

But for this project i will keep it the way i got it but know better next time

Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 24th Mar 2012 23:06
What you have done is impressive for someone who didn't know about view offsets.

I had a look at you code and

The way it is written is a little hard to follow, you really need to think about using;
- constants
- indents
- comments
- sensible variable names
- less goto statements

When debugging your own code, it's sometimes hard to remember what you were thinking when you wrote a particular routine. When debugging someone else's code, its impossible.

While it's up to you how you write your code, if you're asking for help, you really need to meet us half way by making your code easy to follow.

You can't expect people to pick through a big bag of nasty to find the nugget of gold that you need. You need to help people to help you.

As it wasn't too big, and I had some time, I've done you a favour and started the process for you - see attached.

As to the original question, the lines;

screenx#=chopperatx#-16
screeny#=chopperaty#-12

establishes a fixed difference difference between the screen and the chopper.

The sprite position is calculated from the difference between these in updatechopper(), this answer will never change so the chopper will always be at the same position.

And as a guess, it will be 16 Tiles across and 12 down.

Not a maths problem, not a bug, just human error

Attachments

Login to view attachments
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 25th Mar 2012 00:02
thanks....

yeah im trying to comment things better as i go.

Haha...that is the problem isnt it.....thanks

I decided to let the scene go out of bounds anyways as i think it looks neat.

Now i am using simple math collision....would using the sprite collision commands be quicker and better? Since its tile based i figured there was no real point to using sprite collision.


Anyways thanks for the help...looks like i got this under control now.

I will post again when it becomes playable

Login to post a reply

Server time is: 2024-11-23 05:35:47
Your offset time is: 2024-11-23 05:35:47