Is the method() ok?
Is the function ok?
Am I correct in the way Im trying to code this?
No and no. Sorry. It depends on what you want to do really. First of all, the init method takes 3 parameters, which it never uses. Second of all, it would be better IMHO to split Update() function into 3 different methods. An Update() method that actually does the math, and Jump() and Move() methods, that change the required variables, and then to have your input handler (the KeyDown calls) in your main loop, which would then look something like this (not tested):Is the function ok?
Am I correct in the way Im trying to code this?
Const LEFT = -2 Const RIGHT = 2 Local r:Robot = new Robot r.init While Not KeyHit(KEY_ESCAPE) If KeyDown(KEY_LEFT) r.move(LEFT) ElseIf KeyDown(KEY_RIGHT) r.move(RIGHT) EndIf If KeyDown(KEY_SPACE) r.jump() EndIf End While
Is this all OOP is, Just putting everything inside a method or a function and calling it from within the main loop?
No. OOP has many more possibilities than so. Search Google for 'Software Design Patterns' for a rough idea of some of the rather complex problems that OOP allows us to solve relatively simple. Is it natural for there to be less code inside a main loop now that we have OOP ways of coding?
Yes. One of the big mantras of OOP is encapsulation, acheived through the principles of high coherency and low coupling. This means that one of your overall design goals should be to ensure that each type has a very specific responsability, and as few dependancies as possible. Break the problem into it's smallest components, and solve them one at a time - that way you get truely reusable code blocks, so you never have to start from scratch whenever you start a new project.