Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: [Example / Listing] Collision cheking? GM6  (Read 1408 times)

0 Members and 1 Guest are viewing this topic.
[Example / Listing] Collision cheking? GM6
« on: May 24, 2006, 07:20:15 pm »
  • ^This is my sprite comments char
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 226
Code: [Select]
if keyboard_check(vk_left) { global.a_attack=true; x-=4; image_speed=0.5;sprite_index=spr_link_left; global.dir='left' };
if keyboard_check(vk_right) { global.a_attack=true; x+=4; image_speed=0.5; sprite_index=spr_link_right; global.dir='right' };
if keyboard_check(vk_up) { global.a_attack=true; y-=3; image_speed=0.5;sprite_index=spr_link_up;  global.dir='up'};
if keyboard_check(vk_down) { global.a_attack=true; y+=3; image_speed=0.5;sprite_index=spr_link_down;  global.dir='down' };

if !keyboard_check(vk_left)
if !keyboard_check(vk_right)
if !keyboard_check(vk_up)
if !keyboard_check(vk_down)
{
image_speed=0;
image_index=0;
global.a_attack=false


if global.dir='left' {sprite_index=spr_link_left}
if global.dir='up' {sprite_index=spr_link_up}
if global.dir='right' {sprite_index=spr_link_right}
if global.dir='down' {sprite_index=spr_link_down}
}

This is a sword engine movement code(i downloaded from a topic i made in Tutorials) but i dont know how to make this script has a place_free script on it can anyone help me?
« Last Edit: February 10, 2012, 07:16:55 am by Niek »
Logged



i'm working on:

I support and i'm part of the team of:

Goodnight

Once and future Captain
Re: Collision cheking? GM6
« Reply #1 on: May 24, 2006, 08:44:35 pm »
  • With a Capital G
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 706
Code: [Select]
if keyboard_check(vk_left) { global.a_attack=true; if place_free(x-4,y) x-=4; image_speed=0.5;sprite_index=spr_link_left; global.dir='left' };
If that gives any problems, you may have to expand it, like this:
Code: [Select]
if keyboard_check(vk_left) {
global.a_attack=true;
if place_free(x-4,y) x-=4;
image_speed=0.5;
sprite_index=spr_link_left;
global.dir='left';
}
Logged
Re: Collision cheking? GM6
« Reply #2 on: May 24, 2006, 08:54:47 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1635
To get smoother collisions, you may want to replace this:

if(place_free(x-4),y) x-= 4

With this:

Code: [Select]
repeat(4) if(place_free(x-1)) {x -= 1;};

Because it really allows you to scoot up right to collision boundaries rather than shorting stop 4 pixels.
Logged
Re: Collision cheking? GM6
« Reply #3 on: May 25, 2006, 03:01:06 am »
  • ^This is my sprite comments char
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 226
thanks
Logged



i'm working on:

I support and i'm part of the team of:
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.038 seconds with 45 queries.

anything