• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

game programming patterns

so for example the first section is about making a move ojbect to pass other objects in it, so to be able to move any object easily, but i dont know how to go about it in monkey. im still reading it, but my coding isnt very strong
 
Not sure which section you're talking about, but I figured I'd provide some quick code ports I just made so that you have an idea of how to read the code better.

This is from Chapter II, Command section, Undo/Redo subsection
Code:
Class Command Abstract
    Public
    Method Execute:Void() Abstract
    Method Undo:Void() Abstract
End

Class MoveUnitCommand Extends Command
    Public
    Method New(unit:Unit, x:Int, y:Int)
        unit_ = unit
        xBefore_ = 0
        yBefore_ = 0
        x_ = x
        y_ = y
    End
  
    Method Execute:Void()
        xBefore_ = unit_.x()
        yBefore_ = unit_.y()
      
        unit_.moveTo(x_, y_)
    End
  
    Method Undo:Void()
        unit_.moveTo(xBefore_, yBefore_)
    End
  
    Private
    Field unit_:Unit
    Field xBefore_:Int
    Field yBefore_:Int
    Field x_:Int
    Field y_:Int
End

Note: I didn't test this code or anything.
 
wow cool! but moveTo isnt a keyword in monkey though...right? i was really wondering about the one before i believe making a move object
and being able to pass any moveable thing in it. making for less coding.
 
That book makes a lot of generalizations with code and expects that you understand object orientated programming concepts. I'm not sure that you do yet. If you don't, you should look it up.

In general, the code implies this general structure, but doesn't define it.

Function getSelectedUnit()

Class Unit
- Field x
- Field y
- Method moveTo(x, y)
 
ok i see what you mean, my understanding of oop is decent still learning though! thanks for your help!
 
Back
Top Bottom