I Need help

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
nicholas.aycockGA5787
Posts: 11
Joined: Mon Jan 16, 2012 10:40 am

I Need help

Post by nicholas.aycockGA5787 » Tue Jan 17, 2012 3:13 am

I am a beginner and I am going to make my own game. I am enrolled in the academy
and I would like to know if there is a way to draw a line with your mouse and have
an object that is being shot out of a cannon hit that line and bounce off. There
will be different color lines representing the different bounciness. Is this
possible with live code and if so is there a tutorial in which I can figure this
out?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: I Need help

Post by dunbarx » Tue Jan 17, 2012 3:20 am

Easy and fun. It will take a bit of experimentation. That is the fun part.

Read up on the "intersect" function and the "within" function in the dictionary.

Write a script that moves an object around on the screen, and checks to see if there are any collisions. Don't let the object get lost.

Write back when you are good at doing that. Or when you cannot even get started.

Craig Newman

nicholas.aycockGA5787
Posts: 11
Joined: Mon Jan 16, 2012 10:40 am

Re: I Need help

Post by nicholas.aycockGA5787 » Tue Jan 17, 2012 3:43 am

Thank you for that and thanks in advance for any other advice.

robbiefowlerGAIPLH
Posts: 13
Joined: Fri Dec 09, 2011 12:12 pm

Re: I Need help

Post by robbiefowlerGAIPLH » Sun Jan 22, 2012 4:29 pm

nice answer

raulvelazquez
Posts: 54
Joined: Fri Jan 20, 2012 6:08 pm

Re: I Need help

Post by raulvelazquez » Mon Jan 23, 2012 5:21 pm

On a tutorial, from RunRev, it said that the intersection function requires a lot of processing, and is a good idea to use it only if needed.
In that example with an if statement it checked first if the object was close to where it could intersect, and then it use it.
Good idea to know that while coding!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: I Need help

Post by dunbarx » Mon Jan 23, 2012 7:34 pm

I cannot imagine speed or processor burden is an issue with any sort of real-time LC action.

Let me know if I am wrong.

Craig Newman

raulvelazquez
Posts: 54
Joined: Fri Jan 20, 2012 6:08 pm

Re: I Need help

Post by raulvelazquez » Mon Jan 23, 2012 7:50 pm

That was said on the Game Academy, to tell you the truth, Im not sure how much it will impact the app.
Anyone instructor from the Academy to make this clear?

Thank you!

kdjanz
Posts: 300
Joined: Fri Dec 09, 2011 12:12 pm

Re: I Need help

Post by kdjanz » Tue Jan 24, 2012 5:00 am

I believe that the discussion was in the context of Galactic Gauntlet. It uses about 40 pieces for the lower terrain, 40 for the upper foreground and you can have 40+ enemies on the screen, so each frame needs to check 120+ intersections if you brute force it. By using selective IF statements to quickly exclude the 80 pieces that could not possibly intersect as too far away horizontally or vertically, you can save the cycles for the intersects that you truly need. Especially since the intersect uses an alpha transparency comparison, you're dealing with a lot of pixels, so you might as well use a little intelligent optimization where you can.

As someone else said, every cycle you save now gives you more horsepower for v2.0 where there are more sounds, more graphics and faster game play. So you might as well do it now even if the CPU can handle it all right now.

Kelly

raulvelazquez
Posts: 54
Joined: Fri Jan 20, 2012 6:08 pm

Re: I Need help

Post by raulvelazquez » Tue Jan 24, 2012 7:02 am

Thanks for the clarification, and yes, that game was the one I was talking about.

Post Reply