This is odd, being the one to ask for help. but i've got a deadline tomorrow for a contest, so to speed things up, I thought I'd ask for someone experienced who already knew how to just tell me, rather than me taking a while to figure it out. The problem is this, i'm making a game that scrolls, A.K.A. Tanks-5. For Tanks-5, i'm using scrolling, but I hadn't done scrolling in the previous projects, so it's my first attempt. Anyway, the projectile is what I need help with. I've gotten it to move as I want it to, for the most part. It goes in a straight line, and i'm not sure how to get it to do angles. If someone here knows an equation I could use, it would be much appreciated. If you need more details, then ask.
Offline
One of the main points of scrolling is that whatever is displayed on the screen has no relation to the actual "position" of the objects. You'll need to make "absolute position" variables for all your sprites (just call them Position.X and Position.Y, or something like that). You can define that 0,0 is the bottom left-hand corner of the entire area, including what's not on screen. When you initialize a tank, you send it coordinates to the Position.X and Position.Y user-created variables, not the default x and y position (blue).
For example, the tank on the left might have a starting position of (10, 100), and the one on the right might have something like (1000, 100). The actual drawing process would involve taking the camera x and y values -- these are also variables, representing what part of the terrain you're looking at -- and then sending the sprites to ((Camera.X) - (Position.X), (Camera.Y) - (Position.Y)). If you adjust the values of Camera.X and Camera.Y, the entire viewing screen will move around.
So, for a basic sprite that is supposed to scroll:
when gf clicked forever go to x: ((Scroll.X) - (Position.X)) y: ((Scroll.Y) - (Position.Y)) endThis means that you can't use certain movement commands: move (_) steps, change x by (_), etc. You have to replace them with custom commands. Here's a workaround for move (_) steps.
change [Position.X v] by (([cos v] of ((90) - (direction))) * (steps)) change [Position.Y v] by (([sin v] of ((90) - (direction))) * (steps))
Last edited by amcerbu (2012-08-30 01:54:41)
Offline
I'll try it tomorrow morning, I hope it works!
Thanks for getting back quickly.
Offline
It didn't seem to work quite right, not sure what happened. It seemed very odd, like it wasn't supposed to happen.
Unfortunately, I'll have to revert to my back-up plan for the competition, but I'll still need this script for later.
Last edited by sonicfan12p (2012-08-30 21:40:27)
Offline
Still need help with this, although there is no rush now.
Offline