Jump to content

gamemaker stuff


EpicEbilninja
 Share

Recommended Posts

Absolutely nothing. Just some shit you threw together to confuse people. Either that, or you're a terrible coder.

 

if not keyboard_check(vk_up)&& not keyboard_check(vk_right) && not keyboard_check(vk_down)&& not keyboard_check(vk_left)
{
vspeed = 0
hspeed = 0
global.animated=false}
if keyboard_check(vk_left)&& keyboard_check(vk_right)

The last line right there is completely insignificant, it would never be reached because you already made sure that none of the arrow keys are being pressed.

Aside from that, it's obvious that this script controls an object with manual collision detection, and uses the built-in direction, hspeed (horizontal speed), and vspeed (vertical speed) variables to move the object.

 

In the end it actually does something. He just added in a lot of unnecessary checks. As far as I can tell, he wanted it to execute regardless of whether or not the player was pressing a directional key (or any button for that matter). So if you think about it, he didn't need any checks to begin with.

Link to comment
Share on other sites

In the end it actually does something. He just added in a lot of unnecessary checks. As far as I can tell, he wanted it to execute regardless of whether or not the player was pressing a directional key (or any button for that matter). So if you think about it, he didn't need any checks to begin with.

 

I updated my post with more things that were rather pointless in the script. If he wanted to move the player with direction, this would've worked fine.

 

h = -2*keyboard_check(vk_left)+2*keyboard_check(vk_right);
v = -2*keyboard_check(vk_up)+2*keyboard_check(vk_down);
h += !h;
pol = -(180*(h<0)-(arctan(v/h)*180/pi));

x += speed * cos((direction+pol) * pi / 180);
y -= speed * sin((direction+pol) * pi / 180);

That little snippet right there would move the player up, down, left, and right based on the player direction.

 

EDIT:

 

For people trying to figure out whats going on in my code:

  • The first line sets h to -2 if the left key is being pressed or 2 if the right key is being pressed
  • The second line set v to -2 if the up key is being pressed or 2 if the down key is being pressed
  • The third line sets h to 1 if it's 0
  • The fourth line converts h,v from cartesian to polar coordinates
  • The sixth line is simple trigonometry to move the x coordinate in a direction
  • The seventh line is simple trigonometry to move the y coordinate in a direction
  • Like 1
Link to comment
Share on other sites

Absolutely nothing. Just some shit you threw together to confuse people. Either that, or you're a terrible coder.

 

if not keyboard_check(vk_up)&& not keyboard_check(vk_right) && not keyboard_check(vk_down)&& not keyboard_check(vk_left)
{
vspeed = 0
hspeed = 0
global.animated=false}
if keyboard_check(vk_left)&& keyboard_check(vk_right)

The last line right there is completely insignificant, it would never be reached because you already made sure that none of the arrow keys are being pressed.

Aside from that, it's obvious that this script controls an object with manual collision detection, and uses the built-in direction, hspeed (horizontal speed), and vspeed (vertical speed) variables to move the object.

And btw, there's more than 1 pointless thing in there.

  • You're if / thens are contradictory
  • You're calling external scripts to move the player where a simple addition or subtraction would be fine. (even if you're moving relative to the player direction, a simple x += speed * cos(direction*pi/180); y-= speed * sin(direction*pi/180); would suffice)
  • You're apparently only letting all the objects in the game be animated if the player is moving (which makes no sense)
  • You don't need to use manual collision detection, a simple drag and drop of the 'bounce off' or 'move to contact point' buttons would suffice. If there's extra whitespace between the player and the object, just edit the collision masks.

yes, yes, I know

 

it's an old overworld code, it doesn't work 100%

 

I litterally just took the 1st code I found, in an earlier version of my game

 

 

and no, drag and drop is very noob-ish, but so is unneeded codes

 

 

you claim I know nothing, but just wait a bit for me to release the actual game

 

 

 

 

if you tried to make a mario and luigi rpg overworld the way you said, many bad things would happen

 

 

the code went through many changes, and has quite a few unneeded codes, but it is something from my game, and not something off the top of my head to annoy people

 

I updated my post with more things that were rather pointless in the script. If he wanted to move the player with direction, this would've worked fine.

 

h = -2*keyboard_check(vk_left)+2*keyboard_check(vk_right);
v = -2*keyboard_check(vk_up)+2*keyboard_check(vk_down);
h += !h;
pol = -(180*(h<0)-(arctan(v/h)*180/pi));

x += speed * cos((direction+pol) * pi / 180);
y -= speed * sin((direction+pol) * pi / 180);

That little snippet right there would move the player up, down, left, and right based on the player direction.

 

EDIT:

 

For people trying to figure out whats going on in my code:

  • The first line sets h to -2 if the left key is being pressed or 2 if the right key is being pressed
  • The second line set v to -2 if the up key is being pressed or 2 if the down key is being pressed
  • The third line sets h to 1 if it's 0
  • The fourth line converts h,v from cartesian to polar coordinates
  • The sixth line is simple trigonometry to move the x coordinate in a direction
  • The seventh line is simple trigonometry to move the y coordinate in a direction

i'll fix the code then if it makes you happy, but I'm not a terrible creator

 

//if not pressing keys, stops moving
if not keyboard_check(vk_up)&& not keyboard_check(vk_right) && not keyboard_check(vk_down)&& not keyboard_check(vk_left)
{global.animated=false //stops animations
global.move=false} //stops waluigi's movement
//if pressing opposite keys player stops
if keyboard_check(vk_left)&& keyboard_check(vk_right)
{global.animated=false
global.move=false}
if keyboard_check(vk_up)&& keyboard_check(vk_down)
{global.animated=false
global.move=false}
//executes movement
//checks if talking
if global.talk = false
{//checks if holding specific keys(ex: will check if holding up, and no other key
if keyboard_check(vk_up) && not keyboard_check(vk_left)&& not keyboard_check(vk_right) && not keyboard_check(vk_down) //keyboard up
{ddirection = 1 //sets direction(1=up 2=up-right 3=right 4=down-right 5=down 6=down-left 7=left 8=upleft)
global.animated=true //allows animation for both wario and waluigi
script_execute(move_up4) //uses a script to allow player to move up by 4 and check collisions
}
if keyboard_check(vk_up) && not keyboard_check(vk_left)&& keyboard_check(vk_right) && not keyboard_check(vk_down) //up right
{ddirection = 2 //sets direction up right
global.animated=true //allows animation
script_execute(move_up3) //move up 3
script_execute(move_right3)}//move right by 3
if not keyboard_check(vk_down) && keyboard_check(vk_right)&& not keyboard_check(vk_up) && not keyboard_check(vk_left) //keyboard right
{ddirection = 3//sets direction right
global.animated=true // allows animation
script_execute(move_right4)}//moves right by 4
if keyboard_check(vk_down) && not keyboard_check(vk_left)&& keyboard_check(vk_right) && not keyboard_check(vk_up) //keyboard down right
{ddirection = 4//sets direction right down
global.animated=true //allows animation
script_execute(move_down3)//down by 3
script_execute(move_right3)}//right by 3
if keyboard_check(vk_down) && not keyboard_check(vk_left)&& not keyboard_check(vk_right) && not keyboard_check(vk_up) //keyboard down
{ddirection = 5 //sets direction down
global.animated=true//allows animation
script_execute(move_down4)}//right by 4
if keyboard_check(vk_down) && keyboard_check(vk_left)&& not keyboard_check(vk_right) && not keyboard_check(vk_up) //keyboard down left
{ddirection = 6//sets direction down left
global.animated=true//allows animation
script_execute(move_down3)//down by 3
script_execute(move_left3)}//left by 3
if not keyboard_check(vk_down) && keyboard_check(vk_left)&& not keyboard_check(vk_up) && not keyboard_check(vk_right) //keyboard left
{ddirection = 7//sets direction left
global.animated=true//allows animation
script_execute(move_left4)}//left by 4
if keyboard_check(vk_up) && keyboard_check(vk_left)&& not keyboard_check(vk_right) && not keyboard_check(vk_down) //keyboard up left
{ddirection = 8//sets direction up left
global.animated=true//allows animation
script_execute(move_up3)//up by 3
script_execute(move_left3)//left by 3
}}

 

//this checks for collisions, and sets movement speed
if place_free(x,y-4)//checks for solid objects
{//checks for collisions for each specific height
if place_meeting(x,y-4,obj_hblock1) && z<16 {exit}//if lower than 16, stops moving before contact
if place_meeting(x,y-4,obj_hblock2) && z<32 {exit}//if lower than 32, stops moving before contact
if place_meeting(x,y-4,obj_hblock3) && z<48 {exit}//if lower than 48, stops moving before contact
if place_meeting(x,y-4,obj_hblock4) && z<64 {exit}//if lower than 64, stops moving before contact
global.move=true//sets movement for waluigi
if obj_waluigi.y-y<24//checks if too far away from waluigi
{y+=-4}}//move up relatively by 4

I was in a rush, so may not be 100% correct

Link to comment
Share on other sites

What bothered me wasn't your code, it was that you were blaming GM for it being illegible. That's wiping your ass with bread and making a sandwich, then complaining that it tastes terrible because the bread wasn't baked properly.

 

 

btw, repeatedly checking for keypresses will make your game slow. Store them to a variable and check those.

Link to comment
Share on other sites

Calm the hell down, will you?

 

-- Transmitted by an ancient satellite from across the cosmic web. Or my cellphone, if you prefer.

 

he was only trying to help

 

I was wrong, and he corrected me

 

 

angrilly or not, he helped me to find a solution to my problems

I'm actually sort of glad he did, but it would have been nicer without him calling me a failure...

Edited by epicebilninja
Link to comment
Share on other sites

What bothered me wasn't your code, it was that you were blaming GM for it being illegible. That's wiping your ass with bread and making a sandwich, then complaining that it tastes terrible because the bread wasn't baked properly.

 

 

btw, repeatedly checking for keypresses will make your game slow. Store them to a variable and check those.

 

no, that wasn't what was really going on

I thought I knew what I was doing, and left many mistakes in my codes

 

 

thanks for pointing out the problems though, I am still learning about gml, and I made a lot of errors, or unneeded codes in my game

I wasn't blaming gamemaker, I was trying to defend myself because I believed I was right whan I was clearly wrong

 

next time you leave criticism though, please don't call people incompetent, it didn't really leave that deap a wound to me, but some people take it quite harshly

criticism is supposed to be constuctive, to help with further creation, but like me, you thought you knew everything about the situation, and made some rather harsh comments

 

 

 

I guess we both have some areas we need to improve on, just like every other person in the world :)

Link to comment
Share on other sites

yeah, I said sorry to people(jason777), tried to settle things with people I barely know, and made stupid mistakes with gamemaker

 

just a normal day for me, I'm rather used to it by now, but the only difference is it was about something I did rather than someone else(posting an incorrect code)

 

btw, repeatedly checking for keypresses will make your game slow. Store them to a variable and check those.

 

and just so you know, i'd rather keep things understandable to me for the moment

 

it's a simple way that works, and it's WAY faster than the older game(I suggest you don't play it too much, I'll have my engine finished in a month or 2)

 

the slow down is not noticable for most computers, and on those other computers, not by much

Link to comment
Share on other sites

Sorry about being an ass about it. To me, when you posted your code the first time and asked if anybody understood it, it seemed like you were insulting the GML language for your script being illegible.

 

To me it was more like he took my comment on GML the wrong way as if I was saying it was a language made for idiots. Then challenged my knowledge with some code that he thought I would find difficult to understand as if to prove me wrong. The correct way to take my comment: the easier to understand, the better. Anyways, I had fun taking apart and analyzing that code bit by bit. No big deal at all.

Link to comment
Share on other sites

To me it was more like he took my comment on GML the wrong way as if I was saying it was a language made for idiots. Then challenged my knowledge with some code that he thought I would find difficult to understand as if to prove me wrong. The correct way to take my comment: the easier to understand, the better. Anyways, I had fun taking apart and analyzing that code bit by bit. No big deal at all.

 

That's what it seemed like to me as well. After reading the first 5 lines, I was almost certain it was complete bologna code meant to confuse you. But as I read down, it seemed more like he was trying to do something, but was blaming the language for his code being illegible.

 

There are many ways to optimize your code (generally, for any language). Some examples:

  • Instead of checking keypresses repeatedly, store them to variables and use the variables to access them. This is much faster.
  • If you need to swap 2 variables (eg. make A=B and B=A), instead of creating a temporary variable to swap them, do an XOR swap. (A = A XOR B; B = B XOR A; A = A XOR B ) This is much faster.
  • When writing a controller for moving an object that can move in any direction (0-360 degrees) with the arrow keys, convert the key values to cartesian coordinates, and then into polar. This will yield a direction between 0-360 in which can then be used to move the object with some simple trigonometry (x += cos(direction * pi / 180); y -= sin(direction * pi / 180)). The pi / 180 is used to convert degrees to radians. This method is faster, cuts down on code size tremendously, and is fairly useful in 3d graphics as well (such as when you want to move something with respect to the camera angle)
  • When comparing a single variable with several values, switch / case is your best friend. It produces smaller and faster code, and is much easier to read.
  • When writing large files, make it a habit to make a lot of comments throughout the file explaining what is going on. It doesn't matter if your project is planned to be open source or not, those comments will help you pick up where you left off when you decide to take a break, which increases the likelihood that you will actually finish the project.
Link to comment
Share on other sites

I updated my post with more things that were rather pointless in the script. If he wanted to move the player with direction, this would've worked fine.

 

h = -2*keyboard_check(vk_left)+2*keyboard_check(vk_right);
v = -2*keyboard_check(vk_up)+2*keyboard_check(vk_down);
h += !h;
pol = -(180*(h<0)-(arctan(v/h)*180/pi));

x += speed * cos((direction+pol) * pi / 180);
y -= speed * sin((direction+pol) * pi / 180);

That little snippet right there would move the player up, down, left, and right based on the player direction.

 

EDIT:

 

For people trying to figure out whats going on in my code:

 

this would work in your typical oveworld, but not exactly for a mario and luigi rpg overworld

 

trust me, i did something like this before

 

That's what it seemed like to me as well. After reading the first 5 lines, I was almost certain it was complete bologna code meant to confuse you. But as I read down, it seemed more like he was trying to do something, but was blaming the language for his code being illegible.

 

There are many ways to optimize your code (generally, for any language). Some examples:

  • Instead of checking keypresses repeatedly, store them to variables and use the variables to access them. This is much faster.
  • If you need to swap 2 variables (eg. make A=B and B=A), instead of creating a temporary variable to swap them, do an XOR swap. (A = A XOR B; B = B XOR A; A = A XOR B ) This is much faster.
  • When writing a controller for moving an object that can move in any direction (0-360 degrees) with the arrow keys, convert the key values to cartesian coordinates, and then into polar. This will yield a direction between 0-360 in which can then be used to move the object with some simple trigonometry (x += cos(direction * pi / 180); y -= sin(direction * pi / 180)). The pi / 180 is used to convert degrees to radians. This method is faster, cuts down on code size tremendously, and is fairly useful in 3d graphics as well (such as when you want to move something with respect to the camera angle)
  • When comparing a single variable with several values, switch / case is your best friend. It produces smaller and faster code, and is much easier to read.
  • When writing large files, make it a habit to make a lot of comments throughout the file explaining what is going on. It doesn't matter if your project is planned to be open source or not, those comments will help you pick up where you left off when you decide to take a break, which increases the likelihood that you will actually finish the project.

thanks for the help :)

 

i have only been working with gml since the beginning of summer

 

I have enough knowledge to know how gml works, but I just make a lot of errors, and I have a habit of making things more complicated than it needs to be

 

 

gamemaker is all about having fun, and being creative, and it makes it a lot more enjoyable to have support :D

 

Sorry about being an ass about it. To me, when you posted your code the first time and asked if anybody understood it, it seemed like you were insulting the GML language for your script being illegible.

 

nah, people make mistakes all the time, it's really not too big a deal :)

 

as long as we can all have a positive experience, everything is fine

 

 

we both had some disagreements, but it's better now

 

 

 

I actually learned a lot from this experience

Edited by Naxylldritt
Please avoid multi-posting, it's vastly preferred that you edit your posts.
Link to comment
Share on other sites

 

this would work in your typical oveworld, but not exactly for a mario and luigi rpg overworld

 

trust me, i did something like this before

 

yeah, I've been using C for so long, I got used to the syntax. I did make a fixed version after writing that (which I tested), but when I went to post it my internet cut out and I didn't feel like doing it a second time. Basically, just use a separate variable for speed and if h == 0, set pol to -v*90, otherwise do the cartesian to polar conversion.

Link to comment
Share on other sites

yeah, I've been using C for so long, I got used to the syntax. I did make a fixed version after writing that (which I tested), but when I went to post it my internet cut out and I didn't feel like doing it a second time. Basically, just use a separate variable for speed and if h == 0, set pol to -v*90, otherwise do the cartesian to polar conversion.

 

clearly you have more experience than I do with gamemaker, but with my game, I feel it's best for me to learn what I can by myself

 

I learned that the hard way a while back with my older wario and waluigi rpg, getting help from friends, listening to the people saying to use drag and drop, and using 3 previously existing overworld engines

 

 

that did NOT turn out well

 

 

 

It may have been a full year since I started with the game, but I'm back to restarting the game from my own codes

 

 

 

 

thank you for the help with gml, I've been trying to figure it out on my own, and what you have shown did help a little for further understanding

 

i'll do my best to learn more about gml though :D

Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.