View Full Version : point n click games advice?
spires
June 12th, 2009, 02:10 PM
Hi guys.
I'm just in the process of designing a point n click adventure.
(Example: http://www.y8.com/games/Nightmares_The_Adventures_1_Broken_Bones_Complaint )
I'm ok doing the design and the standard animation.
But, I'm not to sure how to do:
- Picking up items
- displaying them in the inventory
- then using them on other items.
Do you know where I can find information on this, or what I need to look in to achieve this?
I know a bit about ActionScript, but i'm not to sure where I need to start.
Thanks for your help :)
TOdorus
June 12th, 2009, 08:23 PM
There is no such thing as enough point & click adventures!
AS2 or AS3? Some things are a bit different depending on what version you use. I am assuming you know how to use (and what the difference is between) local and instance variables. And functions ofcourse. Oh and code on the first frame of the main timeline if you're using AS2. I don't know if you already do this, but it's kind of a standard. This way anyone helping doesn't need to know in what movieclip each piece of code is hidden, as we know all the code to be on the first frame of the main timeline. In AS3 this is less of a problem, as it's almost impossible not to code on the main timeline or document class. Anyhoes:
What you need to look up is arrays and for loops. Simply put an array is a list of items. Numbers, strings, objects, movieclips, buttons, other arrays, or any custom class you can define. Say you have a few movieclips called Shovel, Newspaper and FryingPan you could have a list of them in an array.
var myArray:Array = [Shovel, Newspaper, FryingPan]
trace(myArray[0]) //should trace the Shovel or in AS2 just movieclip
trace(myArray[1]) //should trace the Newspaper or in AS2 just movieclip
trace(myArray[2]) //should trace the FryingPan or in AS2 just movieclip
for loops is a part of code that is looped through, given a condition is met.
var i:int //in AS2 replace :int with :Number
var Length:int = myArray.length
for(i = 0; i < Length; i++){
trace(myArray[i]
}
trace("done")
i = 0 is the initial setting. Here you define what the starting conditions are. Usually people only define one variable here. The goal of this loop is to loop through all the slots (not sure if this is the correct term) in the array and return the content of them. The first slot is at index 0 so i is set to 0. i < Length is the condition that needs to be met if it will loop through the loop again. So as long as i < Length it will run the code again. The last parameter i++ is what happens after a iteration. 1 is added to i. This means that (as long as i < Length) it will go through the next slot. What happens is this.
i = 0
i < Length -> 0 < 3 //= true = another iteration!
trace(myArray[0]) //should trace the Shovel or in AS2 just movieclip
i++
i = 1
i < Length -> 1 < 3 //= true = another iteration!
trace(myArray[1]) //should trace the Newspaper or in AS2 just movieclip
i++
i = 2
i < Length -> 2 < 3 //= true = another iteration!
trace(myArray[2]) //should trace the FryingPan or in AS2 just movieclip
i++
i = 3
i < Length -> 3 < 3 //= false = stop looping
trace("done") //traces "done" :)
Now this can be used for other stuff, like giving your movieclips a position onscreen.
var i:int //in AS2 replace :int with :Number
var Length:int = myArray.length
var theMC:movieClip
for(i = 0; i < Length; i++){
theMC = myArray[i]
theMC.x = 50 + i * 30
theMC.y = 700
}
trace("done")
or recursive
var prevX:Number = 50
var i:int //in AS2 replace :int with :Number
var Length:int = myArray.length
var theMC:movieClip
for(i = 0; i < Length; i++){
theMC = myArray[i]
theMC.x = prevX + 30
theMC.y = 700
prevX = theMC.x
}
trace("done")
On using them on other items, this is a bit more difficult. I'd pass the two items to a function that evaluates if they are a valid combination. It's a bit of an ugly way though, there might be a better way to evaluate then two if functions per combo. (this is AS3, don't know how to do this in AS2 from the top of my head)
function evaluate (ITEM1:movieClip, ITEM2movieClip):void{
if(ITEM1 is Shovel || ITEM2 is Shovel){
if(ITEM1 is Sand || ITEM2 is Sand){
trace("Dig")
}
}
}
But that's more for later really. I suggest you start to know your arrays and for loops first before anything else.
If you also want to implement walking (your character moves to items to pick it up. If I click somewhere it will walk over there), I suggest a nodebased system. Just ask if you do. That's a bit more advanced.
EDIT:
btw I always do code from the top on my head on these forums, so there's a good possibility the above code might not work, but it's really for explaining myself, so that shouldn't be too much of a problem.
spires
June 13th, 2009, 02:48 PM
Thanks for that, thats really helpful.
I've almost finished designing it, then I'm gonna start programming.
Yeah, I know theirs lots of point and click games out there, it's just something that i've always wanted to make :)
I love the old monkey island style games.
Thanks once again :)
TOdorus
June 13th, 2009, 08:05 PM
You're welcome.
MI III still is the prime example for an adventure game for me. I had a swell time playing it so I applaud any point & click endouvers, so if you got any questions I'll be glad to help out.
Gasper
June 19th, 2009, 05:55 AM
Hi ,
Post your gamer griefs and rants on the Griefster (http://griefster.com).
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.