Giter Site home page Giter Site logo

Comments (1)

rlc2 avatar rlc2 commented on August 31, 2024

Added in commit aad03e6.
Find the action name in pygame_maker/actions/action.py inside an ACTION_DATA_YAML dict; the order and number of parameters following the action's name should be supplied as arguments to the function.
Therefore, to call create_object_with_velocity() from user code:

ACTION_DATA_YAML = """
...
    create_object_with_velocity:
      - object: common_object
      - position.x: common_position
      - position.y: common_position
      - speed: common_speed
      - direction:
            type: float
            default: 0.0
      - child_instance:
            type: bool
            default: False
      - relative: common_relative
...
"""

The above excerpt shows the arguments needed:

  1. object is a string naming an object type
  2. position.x is an integer X coordinate
  3. position.y is an integer Y coordinate
  4. speed is a decimal number for the object's movement speed
  5. direction is a decimal number for the direction of motion in degrees
  6. child_instance if true, means create the new object as a child of the current object
  7. relative if true, means interpret position, speed, direction as relative to the current object
    The "current object" refers to the object instance that executed the code block.
    Remember that the language parser won't recognize bare function calls, so you need to use it in an assignment, E.G.:
ok = create_object_with_velocity('obj_UFO', 20+randint(screen_width-40), 0, 1.0, 180.0, false, false)

This should create an instance of obj_UFO at the top of the screen that moves downward at 1 pixel per frame. The variable ok will equal 1 if the action was successfully called, 0 otherwise (these can also be compared with booleans true and false).

from pygame_maker.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.