Rotation[✔]. My next step is...(?)`

Learn how to make certain types of games and use gameEditor.

Rotation[✔]. My next step is...(?)`

Postby Sayato » Wed Apr 01, 2015 7:17 am

Rotation[✔].
My next step is step is movement based on the ships "angle" variable. However, I'm not sure how to access that variable. I'm not exactly sure the spinning is anything more than an animated image. I want to lock it to an variable named ship.angle. ship.angle is pseudo-code, but you get what I'm saying though, right? Tell me how to really code it, please. I'm thinking that I need to find a way to plug these two into game editor...
x = x + cos( angle ) * speed;
y = y + sin( angle ) * speed;
That's the way part 1 worked, anyway.
Any suggestions? I'm going to need to know how to reference the ship's "angle" (↑variable↑) so I can plug stuff into that variable. Then my next step is to move the ship based on "speed" variable...

I believe the current way my game is, it's simply an animated image of the ship spinning.
Generally, I need to know how to access that variable (the ship's "angle" variable). I think there currently aren't any variables. I THINK. I could be wrong. I believe it's just an animated 24 frame image.
I have 3 requests:
1. Tell me how to link the ships rotation variable named "angle". "angle" will increment or decrement when right or left are held.
2. When the "thrust" button (it used to be the "up" key, and I guess it will be that way again) is pressed, have the ship move following the math already mentioned:
x = x + cos( angle ) * speed;
y = y + sin( angle ) * speed;
3. Should I shrink the ship? The reason it's so big is that I intended for the camera to zoom out. If you think this is a bad idea, now would be the best time to fix it, when the project about amounts to just about nothing.
Attachments
Force Disruptor.rar
(4.04 MiB) Downloaded 215 times
2-15-2015.rar
(72.29 KiB) Downloaded 207 times
Sephiroth's strength is unreal. He is far stronger in reality then any story you might have heard about him.
User avatar
Sayato
 
Posts: 39
Joined: Sun Dec 21, 2014 5:12 am
Location: Casper, Wyoming
Score: 1 Give a positive score

Re: Rotation[✔]. My next step is...(?)`

Postby koala » Wed Apr 01, 2015 12:24 pm

Hi, there! :D

The game looks really, really cool.

I don't know how to help you, but maybe this code, which bat78 wrote me, could help you somehow:
bat78 wrote:CONTROLS
Controls are a bit ordinary. You can have more exotic controls just remove the follow mouse and put this in draw actor instead:
Code: Select all
angle = direction(xscreen, 0, xmouse, 0);
directional_velocity = distance(xscreen, 0, xmouse, 0) / 4;

(adapted it to relate only for horizontals).


Keep on with the good work! :D
Phascolarctos cinereus
YouTube: Marko Radivojevic
Google+: Marko Radivojevic
User avatar
koala
 
Posts: 301
Joined: Thu Mar 26, 2015 7:03 pm
Location: Serbia
Score: 30 Give a positive score

Re: Rotation[✔]. My next step is...(?)`

Postby koala » Wed Apr 01, 2015 1:58 pm

Does this help somehow? It is far from perfect, but the idea might be good.
I've moved view and ship to the center.

There will be one Actor that follows rotation of the ship, or to be more precise, it follows the peak of ship.
We'll have a global variable dir:
- dir = 0 when ship isn't rotating
- dir = 1 when ship rotates to the right
- dir = 2 when ship rotates to the left
Ship has 24 frames and Frame Rate is 10. So, animation will be complete in 2,4 seconds, or 2400 ms.
Actor peak should be invisible, Filled Region, but here it is not, so we can follow its moving.

peak Event: Create Actor -> Script Editor
Code: Select all
dir = 1;

peak.x = 0;
peak.y = -40;
Initially ship rotates to the right, so dir = 1.
We set the peak's coordinates. Peak should move from (0, -40) -> (40, -40) -> (40, 40) -> (-40, 40) -> (-40, -40) and so on.

peak Event: Create Actor -> Create Timer - 100 ms, for every new frame of ship; periodic

peak Timer -> Script Editor:
Code: Select all
if (dir == 1) {
    if (x < 40 && y == -40) x += 15;
    else if (x > 40 && y < 40) y += 15;
    else if (y > 40 && x > -40) x -= 15;
    else if (x < -40 && y > -40) y -= 15;
}
else if (dir == 2) {
    if (x > -40 && y == -40) x -= 15;
    else if (x < -40 && y < 40) y += 15;
    else if (y > 40 && x < 40) x += 15;
    else if (x > 40 && y > -40) y -= 15;
}
Length of peak's path is 320 pixels. Ship's frame rate is 24. 320 / 24 = 13.333333... So peak should move 14 pixels, but 15 looks better. You could set another path length, 480. It is dividable with 24 and peak would move 20 pixels, from (0, -60) to (60, -60) to (60, 60) and so on when ship rotates to right.

Now the peak follows the ship's rotation.

Now let's set-up the ship.

ship Event: Key Down: left -> Action: Change Animation Direction: Backward
ship Event: Key Down: right -> Action: Change Animation Direction: Forward
ship Event: Key Down: up -> Action: Change Animation Direction: Stopped

ship Event: Key Down: left -> Script Editor:
Code: Select all
dir = 2;

ship Event: Key Down: right -> Script Editor:
Code: Select all
dir = 1;

ship Event: Key Down: up -> Script Editor:
Code: Select all
dir = 0;

angle = direction(xscreen, yscreen, peak.xscreen, peak.yscreen);
directional_velocity = 3;
Instead 3 you could put speed.

There are also 4 Wire Frame Regions to move the View, and border outside screen.

http://www.mediafire.com/download/dcydbj4cuz9ihkn/DForce.zip
Attachments
DForce.zip
(87.67 KiB) Downloaded 195 times
Phascolarctos cinereus
YouTube: Marko Radivojevic
Google+: Marko Radivojevic
User avatar
koala
 
Posts: 301
Joined: Thu Mar 26, 2015 7:03 pm
Location: Serbia
Score: 30 Give a positive score

Re: Rotation[✔]. My next step is...(?)`

Postby bat78 » Wed Apr 01, 2015 4:01 pm

I don't know what do you mean by most of the phrases.
But you must use directional_velocity, which accelerates the actor according to its angle set.

Code: Select all
xActor.angle += 2; // Add 2 to xActor's angle (0 - 360o)
xActor.directional_velocity = 2; // Accelerate with 2 pixels on each frame
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: Rotation[✔]. My next step is...(?)`

Postby Hares » Wed Apr 01, 2015 8:06 pm

Something to keep in mind when you use the directional_velocity is that when the directional_velocity is zero the angle will reset to zero.
Then when you start moving again, the angle doesn't fit with the animation anymore.

So you want to store that angle by copying it into a new varialbe (in the code below it is anglePrevStore).

Here is some code I came up when i wanted to make a boat move around the screen from a top view.

For this to work you need to declare three variables:
1. an integer "boatMoving"
2. a real "anglePrev"
3. a real "anglePrevStore"

Because your ship has 24 frames of animation to rotate, it will rotate by 15 degrees.
So this code uses the angle that corresponds with the animation to store into anglePrevStore.

On the boat (or ship ...) draw actor event
Code: Select all
if (anglePrev != angle && boatMoving != 0)
{
    animpos = round(angle/15);
    anglePrev = angle;
}

if (directional_velocity > 0.02)
directional_velocity -= 0.01;

if (directional_velocity < 0.02 && directional_velocity > -0.02 && directional_velocity != 0)
{
    anglePrevStore = animpos*15;
    directional_velocity = 0;
    boatMoving = 0;
}
if (directional_velocity < -0.02)
directional_velocity += 0.01;


anglePrev = angle;


To make the boat rotate left add this code to a keydown event
Code: Select all
angle+=5;


To make the boat rotate right add this code to a keydown event
Code: Select all
angle-=5;


And to make the boat move add this to a keydown event
Code: Select all
if (boatMoving != 1)
{
    angle = anglePrevStore;
    boatMoving = 1;
    directional_velocity = 0.1;
}

if (directional_velocity < 2)
{
    directional_velocity+=0.025;
}


Tweak the values to your liking.
And ... don't just copy the code, but try to figure out what it is doing :wink:
User avatar
Hares
 
Posts: 105
Joined: Fri Dec 20, 2013 8:39 pm
Location: Belgium
Score: 14 Give a positive score

Re: Rotation[✔]. My next step is...(?)`

Postby Sayato » Mon Apr 13, 2015 4:47 am

Ha-ha, When I referred to the vessel that's piloted in the game I meant "ship" referring to a SPACE-ship.

Ha-ha. It was my fault, and I understand the misunderstanding.

Actually, in part 1, there was gravity. Gravity doesn't make sense in space. Any ideas? It worked in terms of gameplay, it just made no sense in terms of logic. Any ideas?
Sephiroth's strength is unreal. He is far stronger in reality then any story you might have heard about him.
User avatar
Sayato
 
Posts: 39
Joined: Sun Dec 21, 2014 5:12 am
Location: Casper, Wyoming
Score: 1 Give a positive score

Re: Rotation[✔]. My next step is...(?)`

Postby Sayato » Mon Apr 13, 2015 8:17 am

It's 02:18 A.M. on 4/13/2015 an my mind fell asleep about an hour an a half ago. I'm still up due to caffeine. This is my current project. how do I fix it so the ship doesn't automatically turn?
Attachments
04-13-2015.rar
(87.62 KiB) Downloaded 169 times
Sephiroth's strength is unreal. He is far stronger in reality then any story you might have heard about him.
User avatar
Sayato
 
Posts: 39
Joined: Sun Dec 21, 2014 5:12 am
Location: Casper, Wyoming
Score: 1 Give a positive score

Re: Rotation[✔]. My next step is...(?)`

Postby Sayato » Mon Apr 13, 2015 8:27 am

....And that's even wrong. The ship doesn't even fly straight to begin with, but after a few minutes the ship starts flying slightly off. Thanks for the help, but I'm requesting more.
Sephiroth's strength is unreal. He is far stronger in reality then any story you might have heard about him.
User avatar
Sayato
 
Posts: 39
Joined: Sun Dec 21, 2014 5:12 am
Location: Casper, Wyoming
Score: 1 Give a positive score

Re: Rotation[✔]. My next step is...(?)`

Postby bat78 » Mon Apr 13, 2015 9:59 am

Since you want a lot of help.. I decided to do your entire controls instead.
Omega Wars.zip
Controls, recoil, rotation
(476.18 KiB) Downloaded 215 times


A bit of spoon feeding thought..
I hope you'll at least add some interesting acceleration.
Why is it called Omega Wars? Because these controls are typical for the good SEGA Game "Omega Race".
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: Rotation[✔]. My next step is...(?)`

Postby Sayato » Mon Apr 13, 2015 5:05 pm

I love Sega. I was a HUGE "Phantasy Star Online" addict, like.... 15 years ago.
Sephiroth's strength is unreal. He is far stronger in reality then any story you might have heard about him.
User avatar
Sayato
 
Posts: 39
Joined: Sun Dec 21, 2014 5:12 am
Location: Casper, Wyoming
Score: 1 Give a positive score

Re: Rotation[✔]. My next step is...(?)`

Postby bat78 » Mon Apr 13, 2015 5:28 pm

Sayato wrote:I love Sega. I was a HUGE "Phantasy Star Online" addict, like.... 15 years ago.

Ahh.. I haven't tried that one particularly. (maybe because it is not a SMDII (Sega Mega Drive II) Game)
But was a huge "Top Gear", "Wrestle Mania (The Arcade Game)", "Lion King" addict.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: Rotation[✔]. My next step is...(?)`

Postby Sayato » Mon Apr 13, 2015 5:43 pm

The ship's direction kind of works, but at the same time doesn't .The two problems are
1. The ship starts out spinning, It should be stationary when no input is given.
2. The ship doesn't fly straight and a point of the game is the ship is suppose to contain a sober pilot. I'm thinking perhaps the variable that stores the ships direction should be a variable with the highest accuracy. Back when I programmed "Force Disruptor", I believe the value with the highest definition was the "double".

Is any assistance offered?
Attachments
04-13-2015.rar
(87.62 KiB) Downloaded 183 times
Last edited by Sayato on Mon Apr 13, 2015 7:44 pm, edited 1 time in total.
Sephiroth's strength is unreal. He is far stronger in reality then any story you might have heard about him.
User avatar
Sayato
 
Posts: 39
Joined: Sun Dec 21, 2014 5:12 am
Location: Casper, Wyoming
Score: 1 Give a positive score

Re: Rotation[✔]. My next step is...(?)`

Postby bat78 » Mon Apr 13, 2015 6:13 pm

Could you please do your effort to re-read my message so to download the demo I've especially made for you.
I just did your controls from scratch. The light way.

What are you planning to do with this game anyway?

UPDATE:
It has been downloaded 11 times already. Wow.. what is going on here.
Anyway, the demo I've made for you of the controls you desire omits these two problems of yours.
For diversity, I also made an entire game, with bounce of walls, acceleration, breaks etc.. but I want you to figure out something by yourself too, now when you have most of the game already completed by me. Best of luck.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: Rotation[✔]. My next step is...(?)`

Postby Sayato » Mon Apr 13, 2015 9:52 pm

bat78, this is actually the sequel/remake to my upload, "Force Disruptor". My code was lost by my EX-best friend. https://www.facebook.com/bill.eckerson. The games were programmed by me at a time when I still considered him human. At this time, he also qualified as my best friend. On 9/11/2004 I was ejected 35 feet through my windshield when I was in a car wreck leaving Shoshoni, Wyoming. I have absolutely no memory of the car wreck plus an unknown previous time before the wreck. I've been told that I attended the University of Wyoming, Yet I have no record of it in my memory. I just trust the sources who have informed me. I've been told that I hated it, which is perfectly believable because I'm generally anti-social.

You can try to run those executables. My computer won't. Thanks Bill. But it's okay, the coward somehow blames my mom. (?). I don't understand it, either. I've said it before, but it's like his tight pants would quit fitting if he had the balls too admit to digitally stabbing me in the back. I would have forgave him then. The word "forgave" is in past tense format. Bill is missed because the Bill I was friends with is dead, now. And he took my entire library of games that I've programmed to the after-life.

I would like to fix it so the real ship semi-slowly follows what I will have as a ship, like it's hooked up and being toed by my current ship. The toe-ship will be invisible in the future, on my final compile. The concept of a invisible toe ship with an incredibly short toe cable (it will be invisible in the final compilation) makes sense in my mind. The "toe cable" will be super-short, but it adds a feeling of realism to my game, Right?

And as for the "What are you planning to do with this game anyway?" question, it's just to program a sequel/remake to a old game I programmed, Just because I like to write code......... for now.......
Sephiroth's strength is unreal. He is far stronger in reality then any story you might have heard about him.
User avatar
Sayato
 
Posts: 39
Joined: Sun Dec 21, 2014 5:12 am
Location: Casper, Wyoming
Score: 1 Give a positive score

Re: Rotation[✔]. My next step is...(?)`

Postby bat78 » Mon Apr 13, 2015 10:10 pm

Sayato wrote:bat78, this is actually the sequel/remake to my upload, "Force Disruptor". My code was lost by my EX-best friend. https://www.facebook.com/bill.eckerson. The games were programmed by me at a time when I still considered him human. At this time, he also qualified as my best friend. On 9/11/2004 I was ejected 35 feet through my windshield when I was in a car wreck leaving Shoshoni, Wyoming. I have absolutely no memory of the car wreck plus an unknown previous time before the wreck. I've been told that I attended the University of Wyoming, Yet I have no record of it in my memory. I just trust the sources who have informed me. I've been told that I hated it, which is perfectly believable because I'm generally anti-social.

You can try to run those executables. My computer won't. Thanks Bill. But it's okay, the coward somehow blames my mom. (?). I don't understand it, either. I've said it before, but it's like his tight pants would quit fitting if he had the balls too admit to digitally stabbing me in the back. I would have forgave him then. The word "forgave" is in past tense format. Bill is missed because the Bill I was friends with is dead, now. And he took my entire library of games that I've programmed to the after-life.

I would like to fix it so the real ship semi-slowly follows what I will have as a ship, like it's hooked up and being toed by my current ship. The toe-ship will be invisible in the future, on my final compile. The concept of a invisible toe ship with an incredibly short toe cable (it will be invisible in the final compilation) makes sense in my mind. The "toe cable" will be super-short, but it adds a feeling of realism to my game, Right?

And as for the "What are you planning to do with this game anyway?" question, it's just to program a sequel/remake to a old game I programmed, Just because I like to write code......... for now.......


Well if you like to write code......... for now.......
then do it and don't ask others to do it instead. That doesn't make sense.

Of course I could make this version compatible with your invisible ship or whatever it is.. but I don't understand the point of this thus I don't do such things.
Also you said what you needed.. and I did it. You had no requirements. Now you can fit it on your taste.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Next

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest