Page 1 of 2 [ 21 posts ]  Go to page 1, 2  Next

Robdemanc
Veteran
Veteran

User avatar

Joined: 30 May 2010
Age: 47
Gender: Male
Posts: 2,872
Location: England

29 Sep 2012, 3:58 pm

onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
_x--;
}
if (Key.isDown(Key.RIGHT)) {
_x++;
}
if (Key.isDown(Key.UP)) {
_y--;
}
if (Key.isDown(Key.DOWN)) {
_y++;
}
}

I will make some assumptions here because I don't know where you got the code and what it refers to. The first line is a procedure header, an event procedure. Whatever onClip is then that is the event that has just happened for this procedure to be called and executed.

The rest, which looks like the instrunctions of the onClip event procedure, is giving instrunctions on what should happen if a particular key is pressed.

if (Key.isDown(Key.LEFT)) {
_x--;
}

So if the LEFT key, which I presume is the left arrow key on the keyboard, is pressed down then the value of x will be decremented. So x will decrease. x, I presume is one of the co-ordinates that states where the player is in the scene. x--, with a double minus sign means that you are reducing the value of x. So if x=10 when the key is pressed, this code will decrease its value to 9, then to 8, then 7.....and this will cause the player to move within the scene.

The following 3 statements will cause x to increase (x++), y to decrease (y--), and y to increase (y++).

x and y will be the screen co-ordinates of where the player is, or what the player is focusing on.

So the y plane is vertical and the x plane is horizontal.

I do not know what language this is, but I reckon it is doing what I just said. Perhaps someone else who knows the language can give a more fuller explanation.

BTW - not everyone can program, so don't feel stressed if you find it difficult.



kotshka
Veteran
Veteran

User avatar

Joined: 9 Jun 2011
Age: 39
Gender: Female
Posts: 653
Location: Prague

29 Sep 2012, 4:22 pm

It's for flash. And your explanation honestly makes about as much sense as the code itself, though I appreciate your effort in trying to explain it.

I think I need to do this the other way around. I need to decide what needs to happen in a program then learn each step in how to make that happen, in plain language that doesn't reference other coding ideas, at least until I get some sort of basis. Eventually things should start to click and I should start being able to do things on my own without feeling so lost.

For example, to understand this bit of code, I need answers to all these questions:
1. What does onClipEvent mean? What IS this?
2. What does enterFrame mean? Why is it in brackets? How does it relate to onClipEvent? Why is there an open bracket after it?
3. the "if" part I get. If-then is easy. It means If (this) happens, then something else will happen. I think I can figure out that the structure is
if (this happens) {
then this happens
}
And I can see that the "if" is the key being pressed (although I guess I'd need a list of the tag for every key on the keyboard to be able to do anything else). But the result... "_x--;"? What the hell does that mean? Why is there an underscore there? I get that x refers to the x coordinate of the image, but why does it say --; after it? If it's decreasing the x, why are there two dashes instead of one? Why does it end with a semicolon?

If I could get concrete answers to all that, then I could probably understand what this bit of code is actually doing. But unless I was planning to duplicate exactly this action in the future, it wouldn't help me understand *any* other code. Understanding this wouldn't allow me to do any of my own actual coding.

I think I can make a list of things I actually need to happen to make my idea work.
-First, I have to make the images - that's okay, it will take time but I can do that without help.
-Then, I need to set up the interface. For each image, there will be spots that can be clicked on. That should be simple enough. Click here = change to this image (if moving to a new location) or cross an item off the shopping list (if the correct item is clicked). On the other hand, I have no idea how that works in actual code. Probably with a bunch of flags and abbreviations and symbols that mean nothing to me.
-The more complicated part is that I need to blur the screen. I could make a blurred still image in photoshop with the proper filters, but I haven't played with Flash yet to know if it works the same way, and the blurring must be done in the program so the cursor can unblur certain parts, and to increase/decrease the amount of blurring according to the stress level.
-Speaking of stress, it would have to increase slowly according to time, and the blurriness of the screen and radius of the cursor area would change. Maybe there'd be a visible meter showing how close you are to a meltdown, but I wouldn't know how to go about making something like that.
-The most complicated thing is the cursor. Wherever the mouse cursor moves, the blurring has to be removed for a radius around the cursor and within that radius the image must be magnified. I wouldn't have the slightest clue where to start with that.
-I would also need random background noise to be played, though I'm guessing that wouldn't be too hard - I did learn how to generate random numbers back when I was trying futilely to code a basic dungeon exploration game in QBASIC when I was a kid, and I assume I can make a chance of a sound being played at a particular time using something like that, though certainly the manner of coding it would be completely different.

If someone on here is really patient enough to walk me through some of this, you will have my eternal gratitude. I will bake you banana bread and send it to you wherever in the world you live. But if not, it's okay. It's a lot to ask, I know, and I can always keep asking in other places as well.



thomas81
Veteran
Veteran

User avatar

Joined: 2 May 2012
Age: 42
Gender: Male
Posts: 5,147
Location: County Down, Northern Ireland

29 Sep 2012, 6:14 pm

LabPet wrote:
Brilliant! :)



For a starter idea, I found this video a while back:

[youtube]http://www.youtube.com/watch?v=Stq_fqKqF74&feature=related[/youtube]


I'm not sure that video is highly reliable.

I think this one does a better job of illustrating, it poses the idea that perhaps audio cues (in this case a chaotic piano loop) as opposed to visual might sometimes do a better job of showing autistic traits

[youtube]http://www.youtube.com/watch?v=FmoSrKbRt3M&feature=fvwberel[/youtube]



thomas81
Veteran
Veteran

User avatar

Joined: 2 May 2012
Age: 42
Gender: Male
Posts: 5,147
Location: County Down, Northern Ireland

29 Sep 2012, 6:24 pm

kotshka wrote:
I took an entire course on visual basic in high school. I was the only one in the class who couldn't grasp how the code worked. I can do if...then statements, but beyond that I'm totally lost. I think what I really need is for someone who understands how my mind works to sit down with me and walk me through the process. I say something concrete that I want to do, and they tell me how to do it, explaining each step - what it is, what it does, how it fits in with the overall program. I think in this way I could make progress - but I don't have anyone in my life right now who knows how to code. I've read plenty of books and tutorials and it just makes me stressed. I'm quite intelligent and have no problems with logic, or with language in general (I learn foreign languages very quickly and even difficult grammar comes very easily to me). So when I can't do something that it seems just about everyone else in the world is able to do, I get extremely stressed and anxious and it tends to end in tears.

Tutorials are useless. I searched tutorials and found this one. It started like this:

Quote:
He will move to the left if I press left key, to the right if right key is pressed, and so on.

So the first hero actionscript will be:

onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
_x--;
}
if (Key.isDown(Key.RIGHT)) {
_x++;
}
if (Key.isDown(Key.UP)) {
_y--;
}
if (Key.isDown(Key.DOWN)) {
_y++;
}
}

It’s easy, isn’t it?


And there we go, I already want to cry. WHY does that make something move? What on earth do all those things MEAN? And how DARE that jerk say it's EASY? I can read a reference manual explaining what every command is supposed to do, but it's like picking up a Swahili to Swahili dictionary - all the definitions just reference other things I don't understand. How do people learn what all this means to begin with? Why were all the beginner students in my class able to figure it out immediately and without help after reading a chapter in the textbook, while I just stared at the wall of text feeling lost? I learned to read when I was 3! I should be able to do this.

I did pass that course, by the way, by creating a final project. The other students were making clones of Space Invaders and the like. My project was a program where you enter text into a box, then set a number of seconds as a timer, then hit a button and after that number of seconds, that message would appear on the screen (as a prank error message). I think the teacher would like to have failed me, but he took pity on me because he saw how hard I worked. He advised me not to move on to C++ the next year with the rest.

Quote:
But if I were you I would learn and have fun, you may be suprised how much you learn in a short time.


I've been actively trying for 15 years. I am not exaggerating. Now and then I get overwhelmed with discouragement and quit for a few months, but I always come back and try again. No luck. It's the worst kind of frustration to not be able to do something after trying so hard for so many years. And when I have an idea for a game or digital artwork and present it to some programmers, they all say the same thing: learn to code and do it yourself. It's like a slap across the face every time.


Kotscha, I am in pretty much the same position as you. I mean that genuinely, I suck at maths and everytime I look at a screen full of code i want to cry. Which is a bum deal considering I'm a prospective home game developer albeit struggling with programming. However, I am currently doing a distance learning game development course (specifically in design though not programming).

I'm currently having to compile a portfolio project for my coursework and I am finding it tough not least because of having next to zero programming ability, but also because i have to provide photographic evidence of a game work in progress. I can model and render 3d models, I can write up concept documents for games but the programming end is where i get stuck.

What i did though, was explore different game development environments and weigh up the pro's and con's of each. Eventually I decided that a good language to start with is C#. I started to learn XNA which is a extension of Windows 2010 studio framework ( a development environment that uses the C# language). After reading some books on it I made some modest progress.

One reason i like C# is because from an autistic perspective, the Windows 2010 express studio is nice to read because the different entities from the command library are broken up into different colours. It makes no end of help when you can clearly see where one method ends and another starts. I think this is where i was getting stuck when learning the programming end. Its not necessary to understand what every bit of code means. If you understand the concept of the 'game loop' then you are halfway to understanding how programming a game works.

You may also want to check out Gamemaker on the Yoyo games website (link). Gamemaker is a drag n drop game making tool aimed at people who want to make games without learning to program. The pro version which unlocks all the features and doesnt leave a watermark on your finished game isnt free (its about $30) however you should be able to create some basic Myst style point n click games similar to the sort of genre you're talking about. If you're serious about becoming a professional game developer though it would be better to learn how to program because you will end up using drag n drop as a crutch.

If you want any more help, PM me and we'll talk. I would be more than happy to help you on this. You've got a good game idea going there and I wish I'd thought of it first.



Robdemanc
Veteran
Veteran

User avatar

Joined: 30 May 2010
Age: 47
Gender: Male
Posts: 2,872
Location: England

30 Sep 2012, 3:29 am

I just looked up on google and found an explanation:

The onClip event runs for each frame of a movie. So in your example it will execute every single frame of a movie. All movies are simply collections of still images, so every time the image changes the onclip event is called and the code executed. In the example you gave the program is checking to see if the up, down, left, or right keys are being pressed.

the x--, or x++ is just a way of decreasing or increasing the value of x. Many languages use this syntax. Others will put it differently and say

x = x + 1, or x = x -1.

but x ++ means the same as x = x + 1, and you are just adjusting the value of x.

Enterframe sounds like it is the name of the event and it is in brackets because it is being passed to the onClip event handler.

if you want something to happen at an event (i.e. something happens like the user pressing a key) you must have an event handler (which is a piece of code) to do the things you want.

In your example the enterframe event is passed to the onclip event handler and the values of x and y are changed depending on which key is being pressed.



kotshka
Veteran
Veteran

User avatar

Joined: 9 Jun 2011
Age: 39
Gender: Female
Posts: 653
Location: Prague

30 Sep 2012, 6:36 am

Thanks for the feedback guys. And Robdemanc, your explanation does actually help a bit, although I'm still quite confident that I wouldn't be able to write something like this. I'm starting to get how some of it works, but I would never be able to construct something like that on my own, at least not yet.

But I'm not giving up. I have to finish some stuff for work now, then I hope I'll have enough focus left to start working on a sample image for the game. Then I can load up Flash and see if I can't figure out how to make some things happen. If I have specific questions, I'll just have to ask on here (or other web sites - if anyone has any suggestions for programming help sites that are newbie-friendly, send 'em on over!). I really believe that I can do this if I just keep at it, keep patient, don't let myself get overwhelmed, and find one or two people to answer my questions. It seems even just here there's already plenty of people willing to help, so that's encouraging. :)