Three easy Flash questions

Started by
9 comments, last by Antheus 16 years, 11 months ago
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) { return -1; } Return(1); } I'm very thankful for any response
Advertisement
Is this homework?
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).
Noone? I mainly need help with the third question, that's just badass code to me. Please.
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

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) {<br>return -1;<br>}                                    // Missing a } here<br>Return(1);                           // Wrong syntax for return<br>}<br>// Also, if you want to return true or false, just return 'true' or 'false', instead of -1 or 1<br><br></pre><br><br>It's hard to tell exactly what to fix because I have no idea what the code is "supposed" to do.<br><br>Also, what version of ActionScript are you using? If it's 3 then you'll need to explicitly type those functions.
Quote:Original post by Period
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).



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.
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?
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?
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.

This topic is closed to new replies.

Advertisement