Jump to content


Photo

Some(or Many?) Begginner Problems


  • Please log in to reply
7 replies to this topic

#1 gaphary

gaphary

    GMC Member

  • New Member
  • 17 posts

Posted 17 January 2010 - 09:49 PM

After losing my hard-drive I decided to start working with Game Maker again as I had lost the whole project I had worked on. I'm starting from scratch with a different perspective game and I currently have some problems.

(1)Right now, my true problem is that my character may not move left or right when it collides with the platform object. It still can jump and move left and right in the air although.

My code for movement is:
if keyboard_check(vk_right) &&place_free(x+6,y) {x+=6}
if keyboard_check(vk_left) &&place_free(x-6,y) {x-=6}
if keyboard_check_pressed(vk_up) &&! place_free(x,y+6) {vspeed=-7}
My collision code is:
if vspeed>0 && !place_free(x,y+vspeed) {move_contact(270)} vspeed=0
This problem may be due to my minuscule object and irregular platform sizes, but I highly doubt it.

(2)Another problem that I have is finding out how to delay my bullet timing. For my bullet actions, I am not using coding, but using "Create a Moving Instance" in "Glob Left Button", allowing the bullets to be shot in the direction of my mouse.

(3)Finally, I want all bullet instances to be instantly destroyed if they leave the room. Not only will this help me with my current problem, but will allow me to create a death action for my Player if it falls.

Hopefully some of you guys will be able to help, thanks if you can.
PM me if you NEED a copy of the current .gmk file.

Edited by gaphary, 18 January 2010 - 07:04 PM.

  • 0

#2 unscmaster

unscmaster

    GMC Member

  • New Member
  • 946 posts

Posted 17 January 2010 - 10:14 PM

Easy enough.
For problem 2 just put this in you global left pressed event.
if alarm[0]<1
{
instance_create(x,y,object_bullet);
alarm[0]=room_speed*<seconds between fire>;
}

make sure you make an alarm[0] event and put a comment in it so it doesn't get deleted.
For problem three, put

instance_destroy();

in the other outside of room event.
  • 0

#3 gaphary

gaphary

    GMC Member

  • New Member
  • 17 posts

Posted 17 January 2010 - 10:27 PM

Thanks for solving problem three, that was an easy solve.

For number two I tried putting in what you told me but it still doesn't seem to delay at all.

I used:
if alarm[0]<1
{
instance_create(x,y,Bullet_1);
alarm[0]=room_speed*(1);
}
In an event action in "Glob Left Button"

and I made the comment "Alarm" in the Alarm0 event. What went wrong?

Oh btw, anyone have any idea for my #1 problem?

*EDIT* : Not only did it not work, but it created non-moving instances of the bullet on top of my Player. Since there is no instance_destroy or anything they just float there too.

Edited by gaphary, 17 January 2010 - 10:29 PM.

  • 0

#4 Poris

Poris

    GMC Member

  • New Member
  • 533 posts

Posted 17 January 2010 - 10:36 PM

Hey there. I can't see any problems with you code for problem number 1, so I'm assuming that it's somewhere else. Try looking at a platform engine.

For problem number 2:

Create Event:
can_shoot=true;

Step event:
if can_shoot=true
{
	//Shoot
	alarm[0]=15;
	can_shoot=false;
}

Alarm 0 Event:
can_shoot=true;

  • 0

#5 unscmaster

unscmaster

    GMC Member

  • New Member
  • 946 posts

Posted 17 January 2010 - 10:44 PM

Oh yeah. I forgot that you asked for them to move. Sorry, here you go.

in the create event of the bullet use

motion_set(global.mousedirection,4);

and set mousedirection variable in the controller object with this in the step event.

global.mousedirection = point_direction(object_shooter.x,object_shooter.y,
mouse_x,mouse_y);


This sets the motion and direction of the bullets. The alarm should work, but you wouldnt be able to tell if they wernt moving.

As for the first problem, there are so many ways to do that that I'm going to save that for later if no one answers that by then.

Edit: Use poris's code for the alarm but remember that you can change the alarm to alarm[0]=roomspeed*<seconds> so you know how many seconds it takes to shoot. For more than one a second just use roomspeed/<bullets per seconds>.

Edited by unscmaster, 17 January 2010 - 10:49 PM.

  • 0

#6 gaphary

gaphary

    GMC Member

  • New Member
  • 17 posts

Posted 17 January 2010 - 10:52 PM

There is an error because it does not recognize "global.mousedirection" even though I used it in my Player's step event.

___________________________________________
ERROR in
action number 1
of Create Event
for object Bullet_1:

Error in code at line 1:
motion_set(global.mousedirection,4);
^
at position 19: Unknown variable mousedirection


*EDIT* Leaving home for a few hours, will respond to all responses later.

Edited by gaphary, 17 January 2010 - 11:05 PM.

  • 0

#7 unscmaster

unscmaster

    GMC Member

  • New Member
  • 946 posts

Posted 18 January 2010 - 12:17 AM

yeah i was afraid of that. just define it in the create event by saying global.mousedirection=0;
  • 0

#8 gaphary

gaphary

    GMC Member

  • New Member
  • 17 posts

Posted 18 January 2010 - 04:22 AM

Thanks so much unscmaster! The time-delay works like a charm! Now the only problem I have is not being able to move. I also have another wall jump problem I forgot to address but I may simply post that in another post later. If anyone can help me with this collision problem, it would be greatly appreciated.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users