ENIGMA Forums

Outsourcing saves money => Programming Help => Topic started by: rxadmin on September 08, 2013, 02:03:52 pm

Title: check on what boundary is hit when colliding with the room edges
Post by: rxadmin on September 08, 2013, 02:03:52 pm
Hi,

First of all: I'm really new on Enigma. Just discovered the tool last weekend so forgive me for asking questions that are probably asked before.  :ohdear: However, I checked the documentation and the forum posts but did not really found the answer.

I'm playing around with Enigma, trying to make a simple ball-game. You probably know, bal+plate, some bricks to hit and when hitting the walls, the velocity of the ball is inverted. No big deal.

In this game, the room has 3 edges where the velocity inverts (left, right, top) and one that edge that is game over (bottom). So in the collision event I wanted to inspect what edge of the room the ball is colliding with. That turned out to be more difficult than I expected.

After playing around a bit a came upon the section explaining the file: events.res. So I thought if events can be defined, why not just define them. I found the entry "intersect boundary"

Code: [Select]
boundary: 7
Name: Intersect Boundary
Mode: Special
Case: 1
Sub Check: (bbox_left < 0) or (bbox_right > room_width) or (bbox_top < 0) or (bbox_bottom > room_height)

So I made a copy like this (just showing the left intersection here):

Code: [Select]
boundaryleft: 7
Name: Intersect Left Boundary
Mode: Special
Case: 1
Sub Check: (bbox_left < 0)

Nice and easy, I thought. However, to my surprise the event never showed in the Enigma IDE.  :( :(
I guess I'm missing something fundamental. Can anyone explain what part I'm missing here?

Regards,
Ruud
Title: Re: check on what boundary is hit when colliding with the room edges
Post by: Goombert on September 08, 2013, 02:18:43 pm
Haahha, hello and welcome rxadmin! I am really surprised to see you jump right into editing ENIGMA's source code. I am also glad to hear the set up went so well for you. Now the reason why the events do not show in the IDE, is because that is a separate project, LateralGM is an abstract IDE for Game Maker so that regular Game Maker users can use it without ENIGMA in case for w/e reason they don't want to use ENIGMA. ENIGMA just takes your project and compiles and executes it, the IDE is for editing the project files, we just redistribute LateralGM because our projects merged together some time ago and I have since become a developer for both projects.

There is tons of more information on our Wiki lying around, especially under "Sister Projects"
http://enigma-dev.org/docs/Wiki/Main_Page

Now Game Maker does not allow adding custom events, ENIGMA and LateralGM do by virtue of them being free and open source, there is zero guarantee that any events you add would work in regular Game Maker and your project may become incompatible.

But continuing on, if you do want to add a new event to the IDE, you would simply do so in these two files...
https://github.com/IsmAvatar/LateralGM/blob/master/org/lateralgm/resources/sub/MainEvent.java
https://github.com/IsmAvatar/LateralGM/blob/master/org/lateralgm/resources/sub/Event.java

That said I am fairly certain you are over complicating and there is a much simpler solution than adding a custom event.

Code: [Select]
if (bbox_left < 0) {
  // left boundary intersection
} else if (bbox_right > room_width) {
  // right boundary intersection
} else if (bbox_top < 0) {
  // top boundary intersection
} else if (bbox_bottom > room_height) {
  // bottom boundary intersection
}

You can just simply use that code in your collision boundary event.  (Y)
Title: Re: check on what boundary is hit when colliding with the room edges
Post by: TheExDeus on September 08, 2013, 03:48:12 pm
Quote
But continuing on, if you do want to add a new event to the IDE, you would simply do so in these two files...
It would be good if data in those files could be externally defined like the events.res. So you wouldn't have to recompile LGM just to use those changes.

Quote
You can just simply use that code in your collision boundary event.  (Y)
Agreed about the complication. Everything can be done straight in EDL. Even better of course would be to use that code in step event though, as the boundary event already checks that (as seen in the OP posted code). That should in theory be faster when check is true (object colliding with boundary) and the same when the check is false.
Title: Re: check on what boundary is hit when colliding with the room edges
Post by: rxadmin on September 09, 2013, 01:07:38 pm
Thanx a lot guys.

I already had the feeling there had to be a much easier way. Glad to see there is. I guess the problem here is  me still being a newbie. Lets see if I can change that soon :)
Title: Re: check on what boundary is hit when colliding with the room edges
Post by: Goombert on September 09, 2013, 01:29:38 pm
No problem, and good luck to you  (Y)