Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Line of Sight?

Author
Message
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 25th Mar 2015 23:01
Hi, first of, got to say I'm loving AppGameKit, I played with the demo for a few days and purchased the full version as soon as I saw the nice 33% off (thanks TGC).

So... I have this idea for a game and I need to establish 'Line of Sight' for my sprites, before I go reinventing the wheel and/or over complicating things with dummy sprites and such I was wondering if there is an in-built method or using ray-casting would be a better option?

What would be the preferred (resource friendly) method ?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 26th Mar 2015 08:45 Edited at: 26th Mar 2015 08:46
The easiest way would be raycasting yes. You can check for sprites in a particular group too so a check something like this would work nicely:


This relies on you setting the obstacles into a particular group IE:


Welcome to the forums by the way!

Using AppGameKit V2 Tier 1
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 26th Mar 2015 17:39
Hi, thanks for the welcome and the code, I knew there had to be a simpler way than the complex way I had planned in my head

for any other noobs finding this post looking for the same, heres an example of it in action

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 26th Mar 2015 18:27
For your reference you can create a constant using a command. For example:


Using AppGameKit V2 Tier 1
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 26th Mar 2015 21:46
ok, that kinda goes against my understanding of what a constant is but it's definitely a handy macro system, thanks for the tip
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 27th Mar 2015 09:14
Well, it always calls the same compile-time code so in that respect it's constant but I know what you mean. You can't put variables into commands called in this way.

Using AppGameKit V2 Tier 1
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 27th Mar 2015 11:29
oh I see, the command input must be constant, making the declared constant more like a switch for the command output, I like it and already am making use of it lol

while on the subject of constants, I don't see much use of them in the various examples, bearing in mind this switching capability is there much overhead to using them, say for example if I make an include file defining constant values for the various function argument values for my own ease of use and remembrance, would this have much of an impact on my finished app's size and performance bearing in mind I'll be declaring lots constants I don't actually use in every project, or best to only define constants I actually use, I know it sounds like a real no brainier but I'm a WinAPI programer and kinda used to including loads of code I never actually use!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 28th Mar 2015 10:24
Using constants is normally quicker than calling the function directly I believe and having a set of constants in a library is an extremely useful way of keeping consistency in your code. The size of your project might be very slightly larger but not enough to worry about.

Using AppGameKit V2 Tier 1

Login to post a reply

Server time is: 2024-11-23 11:34:05
Your offset time is: 2024-11-23 11:34:05