# Three easy Flash questions

## Recommended Posts

I have the three following questions: 1. If you're creating a simple game where you can move with the keyboard-arrows, collide with things, shoot and have three lives - why is it so important to write a manuscript and draw a sketch before you sit down and create the game? 2. When you write the code you can do it in two different ways. You can write all the code directly in your gameloop or you can break it down in small functions and just call on these from the gameloop. What are the advantages and disadvantages with these two ways of designing a game? 3 And for the third question I need this following code corrected and described what is wrong, how it should be (the correct code) and an explanation of what the code is supposed to do: function randomize { /*this way you can insert explanations over several lines without the code breaking*/ randNum = int(math.random()*60); } function evalRand(num, count) { for(s=o; s<=count;) { if(num == myArray[s]) { return -1; } Return(1); } I'm very thankful for any response

#### Share this post

##### Share on other sites
Is this homework?

#### Share this post

##### Share on other sites
Homework is the wrong question, it's a live test I have tomorrow and this is pre-questions to get an idea of what's coming up. I would use the information just like I'd use any Wikipedia site, in other words. I'm for example supposed to write that code down tomorrow and correct it myself (using information I've gathered).

#### Share this post

##### Share on other sites
Noone? I mainly need help with the third question, that's just badass code to me. Please.

#### Share this post

##### Share on other sites
what do you need help understanding with it?

From what I can tell (I am NOT perfect with ActionScript, though this is basic enough), it looks like you are creating one function. One that will create randomization. The other will iterate through the loop and check to see if the num parameter is equal to the number of s. If it is, it needs to return -1, which I presume would mean error. If it is not, then loop again, but if the loop is over then return from the code with 1.

Again...I could have read this wrong, so anyone please feel free to change what I said.

Chad

#### Share this post

##### Share on other sites
Hmm did you try plugging it in to a compiler? That would tell you a lot.

Anyway...

function randomize {                 // need to write () after randomizerandNum = int(math.random()*60);     // Need to say "var" before randNum. Math needs to be capitalized }                                    // You probably want to return randNumfunction evalRand(num, count) {for(s=o; s<=count;) {             // Probably want s=0 not s=o. Also you need to say "var" before s=0// Also, you probably want to add s++ to the for loop. Also, you should probably // iterate over myArray.length instead of count. Also, you probably want to say// s < count and not s <= countif(num == myArray[s]) {return -1;}                                    // Missing a } hereReturn(1);                           // Wrong syntax for return}// Also, if you want to return true or false, just return 'true' or 'false', instead of -1 or 1

It's hard to tell exactly what to fix because I have no idea what the code is "supposed" to do.

Also, what version of ActionScript are you using? If it's 3 then you'll need to explicitly type those functions.

#### Share this post

##### Share on other sites
Quote:
 Original post by PeriodHomework is the wrong question, it's a live test I have tomorrow and this is pre-questions to get an idea of what's coming up. I would use the information just like I'd use any Wikipedia site, in other words. I'm for example supposed to write that code down tomorrow and correct it myself (using information I've gathered).

Go to sleep, take the exam, fail, and learn a valuable lesson.

There's little anyone can do to help you here, since even the simplest answer one could give would completely answer the question.

1) This is discussion and has to deal with project management
2) Topic: Source code organization
3) Extremly poor code example. It's impossible to figure out what it *should* do. Either discuss on syntax errors, or theoretize about what all this code could do. But the sample as a whole doesn't have any coherent meaning, or some if is missing.

#### Share this post

##### Share on other sites
The code is for creating a game, and a very simple one. But I'm starting to get a hang of the "code organization" and my biggest problem now is the question number 2. Anyone has an answer for this?

#### Share this post

##### Share on other sites
Can you at least *pretend* to try to answer these on your own? This feels too much like we are doing your homework. What do YOU think the answer to #2 is?

#### Share this post

##### Share on other sites
Oh, it's nothing like that actually. I'm done with question 1 and 3 (kinda) and I've honestly been working with the #2 with my buddies (taking the same test) for a good while now.

My guess?

Since I barely know what question 2 means I'll have to start with understanding the question, and I'm guessing that it's something like this: Writing it all in your gameloop (?)means you have all the actionscript gathered at 1 place, like an own layer. Or what the heck is a gameloop? To be honest I'm completely unable to answer this question, I can't even get a grip of what the question is, hence me coming here asking for help. I've been working in Flash MX for more than five solid hours now and I just can't get this right, as you might have noticed I'm not very good at this.
The reason why I haven't learned shit from my lessons are that I haven't been able to attend them. Having two classes at the same time is hard (I had to add a class: game programming to get the required points to graduate). This is pretty much my only way to get this grade and graduate, but I also understand that people aren't really willing to waste their time on this. But frankly, I'm taking the test in 5 hours and it's 03.00 here. I wouldn't be staying up if I didn't have to.

#### Share this post

##### Share on other sites
Quote:
 The reason why I haven't learned shit from my lessons are that I haven't been able to attend them. Having two classes at the same time is hard (I had to add a class: game programming to get the required points to graduate). This is pretty much my only way to get this grade and graduate, but I also understand that people aren't really willing to waste their time on this. But frankly, I'm taking the test in 5 hours and it's 03.00 here. I wouldn't be staying up if I didn't have to.

The reason people are unwilling to help is because these are such trivial questions.

Game loop is covered by every tutorial about game programming. Google would give you an answer in 7 seconds. Third of those would be wikipedia, which describes complete structure of a game, including game loop.

And putting in "functions programming" brings me, once again, to wikipedia, where the first paragraph answers your question completely.

No, sorry, two classes at same time isn't an excuse. Try overtime at a full-time job in a start-up, family, BSc course and student loans.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

## Sign in

Already have an account? Sign in here.

Sign In Now

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627638
• Total Posts
2978330

• 10
• 12
• 22
• 13
• 34