### Author Topic: SCI1.1: Making the room edges a bit easier to hit  (Read 2810 times)

0 Members and 1 Guest are viewing this topic.

#### Cloudee1

##### SCI1.1: Making the room edges a bit easier to hit
« on: June 22, 2015, 12:45:05 PM »
I added this code into a post somewhere, but it is getting kind of hard to find now so I figured I would stick it in this board. If you are using dosbox and the mouse is not locked inside your game window, it can be kind of a pain sometimes to get your ego close enough to the edge of the screen to trigger the room change. This will add a gutter around the edge, so that really you only have to get close now. How close is entirely up to you.

First in the main script, let's go ahead and add a new global variable. It is this variable which will let you set how far from the edge should trigger the new room.

Code: [Select]
`  gEdgeDistance = 10`
Now in the ego script. We are going to change the doit method of the ego actor. In this, I use the gEdgeDistance literally for the x dimensions, but that number seems a bit big when talking in the y. So I make it look at half that distance for the y's.

Code: [Select]
`    (method (doit)        (super:doit())        = edgeHit             (if (<= x (+ 0 gEdgeDistance))             4            )            (else                (if (>= x (- 320 gEdgeDistance))                 2                )                (else                    (if (>= y (- 190 (/ gEdgeDistance 2)))                     3                    )                    (else                        (if (<= y (+ (send gRoom:horizon) (/ gEdgeDistance 2)))                         1                        )                        (else                         0                        )                    )                )            )    )`
And there you go, much easier now to travel between rooms.

#### troflip

##### Re: SCI1.1: Making the room edges a bit easier to hit
« Reply #1 on: June 22, 2015, 02:47:39 PM »
Cool, I'll see if I can work this into the template game
Check out my website: http://icefallgames.com

Page created in 0.121 seconds with 22 queries.