Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

[SZUKAM]Mentora


Rekomendowane odpowiedzi

Opublikowano

Witam!

Szukam Mentora, który pomoże mi się nauczyć programować

w języku JSON. Chcę programować stadiony do haxballa.

Trza przerobić jakoś to:

[/center]

// ****************************************************************
// This is a simple HaxBall stadium meant to be used as an example.
// ****************************************************************

// HaxBall stadiums are a JSON object composed of lists of vertexes, segments, planes, discs, goals and traits.

// A Vertex is an invisible solid 2d point which discs can't go through.
// A Segment connects two vertexes with a wall. They can be visible or invisible, curved or straight. (It is recommended that the vertexes connected by a segment have the same physical properties as it, otherwise the corners of the segment will behave different than the sides.)
// A Plane defines a one sided boundary, objects can only be on one side of a plane.
// A Disc defines a physical disc (Same as the goal posts, the player discs or the ball).
// A Goal is a segment defined by two points, when the ball passes through this line a goal will be scored.
// A trait is an optional feature which lets you avoid repetition by defining properties which are common to many objects.

// Vertexes, Segments, Planes and Discs all share the following properties:
// "bCoef" : <Number from 0.0 to 1.0> - Defines the bouncing coefficient.
// "cMask" : <Array of collision layers, eg: ["ball", "red", "blue"]> - Stands for collision mask, it defines which layers this object can collide with. 
// "cGroup" : <Array of collision layers, eg: ["ball", "red", "blue"]> - Stands for collision group, it defines in which collision layers this object lives.
// "trait" : <Name of a trait to inherit from> - When this property is specified the object will inherit the properties defined on the trait.

// In addition there are properties specific to each one:

// Vertexes:
// "x" : <Number> - The X coordinate of the vertex.
// "y" : <Number> - The Y coordinate of the vertex.

// Segments:
// "v0" : <Integer number> - The index of a vertex to connect with this segment.
// "v1" : <Integer number> - The index of the other vertex to connect with this segment.
// "curve" : <Angle in degrees from -350.0 to 350.0> - How much this segment curves.
// "vis" : <true or false> - Wether this segment is visible or not.
// "color" : <Color> - Defines the color of the segment.

// Plane:
// "normal" : <[Number, Number]> - The normal(direction vector) of the plane.
// "dist" : <Number> - The distance to <0,0>.

// Disc:
// "radius" : <Number> - The radius of the disc.
// "invMass" : <Number >= 0 > - The inverse of the mass, the closer to 0 the heavier this object is. (Discs with 0 invMass can't move and act as static objects)
// "color" : <Color> - The fill color of the disc.

// Goal:
// "p0" : <[Number, Number]> - First point of the goal.
// "p1" : <[Number, Number]> - Second point of the goal.
// "team" : <Either "red" or "blue"> - The team whose this goal belongs to.


// ***********************
// Some other useful info:
// ***********************

// Collision layers are defined as arrays of the following strings:
// "ball" - The collision group of the ball.
// "red" - The collision group for red players.
// "blue" - The collision group for blue players.
// "wall" - The default collision group for all stadium objects.
// "redKO" - A collision group players will only collide with during the red kickoff. (Useful for kickoff barriers)
// "blueKO" - A collision group players will only collide with during the blue kickoff. (Useful for kickoff barriers)

// Colors can be defined in two ways (always RGB):
// * As a hexa string, eg "F7A2DD"
// * As an array of numbers from 0 to 255, eg: [255, 128, 0].


// ****************************************
// Here's the annotated stadium definition:
// ****************************************

{
"name" : "Simple", // Set the name of the stadium
"width" : 450,     // width and height only constrain the camera scrolling.
"height" : 250,

"spawnDistance" : 200, // Set how far from the ball the teams will spawn

"bg" : { "type" : "grass", "width" : 400, "height" : 200, "kickOffRadius" : 75, "cornerRadius" : 0 }, // Set the background. This is only visual, it doesnt' affect the physics at all.

// The list of vertexes:
"vertexes" : [
	// Left side of the ball area:
	{ "x" : -400, "y" : 200,  "trait" : "ballArea" }, // Index 0 - Bottom corner.
	{ "x" : -400, "y" : 75,   "trait" : "ballArea" }, // Index 1 - Bottom goal post.
	{ "x" : -400, "y" : -75,  "trait" : "ballArea" }, // Index 2 - Top goal post.
	{ "x" : -400, "y" : -200, "trait" : "ballArea" }, // Index 3 - Top corner.

	// Right side of the ball area:
	{ "x" : 400, "y" : 200,  "trait" : "ballArea" }, // Index 4 - Bottom corner.
	{ "x" : 400, "y" : 75,   "trait" : "ballArea" }, // Index 5 - Bottom goal post.
	{ "x" : 400, "y" : -75,  "trait" : "ballArea" }, // Index 6 - Top goal post.
	{ "x" : 400, "y" : -200, "trait" : "ballArea" }, // Index 7 - Top corner.

	// Vertexes involved on the kickoff barrier:
	{ "x" : 0, "y" :  250, "trait" : "kickOffBarrier" }, // Index 8 - Bottom center.
	{ "x" : 0, "y" :   75, "trait" : "kickOffBarrier" }, // Index 9 - Bottom of the kickoff circle.
	{ "x" : 0, "y" :  -75, "trait" : "kickOffBarrier" }, // Index 10 - Top of the kickoff circle.
	{ "x" : 0, "y" : -250, "trait" : "kickOffBarrier" }  // Index 11 - Top center.
],

// The list of segments:
"segments" : [
	// Left side ball area walls:
	{ "v0" : 0, "v1" : 1, "trait" : "ballArea" }, // Connects bottom corner to bottom goal post.
	{ "v0" : 2, "v1" : 3, "trait" : "ballArea" }, // Connects top corner to top goal post.

	// Right side ball area walls:
	{ "v0" : 4, "v1" : 5, "trait" : "ballArea" }, // Connects bottom corner to bottom goal post.
	{ "v0" : 6, "v1" : 7, "trait" : "ballArea" }, // Connects top corner to top goal post.

	// Goal nets:
	{ "v0" : 1, "v1" : 2, "trait" : "goalNet" }, // Connects left bottom to left top post.
	{ "v0" : 6, "v1" : 5, "trait" : "goalNet" }, // Connects right bottom to right top post.

	// Kickoff barriers:
	{ "v0" : 8, "v1" : 9, "trait" : "kickOffBarrier" },                                        // Connects bottom center to kickoff circle bottom.
	{ "v0" : 9, "v1" : 10, "trait" : "kickOffBarrier", "curve" : 180, "cGroup" : ["blueKO"] }, // Connects Kickoff circle top and bottom, curve = 180 makes half a circle.
	{ "v0" : 9, "v1" : 10, "trait" : "kickOffBarrier", "curve" : -180, "cGroup" : ["redKO"] }, // Connects Kickoff circle top and bottom again, curve = -180 makes the other half.
	{ "v0" : 10, "v1" : 11, "trait" : "kickOffBarrier" }                                       // Connects kickoff circle top to top center.
],

// List of goals:
"goals" : [
	{ "p0" : [-400, 75], "p1" : [-400,-75], "team" : "red" },
	{ "p0" : [400, 75], "p1" : [400,-75], "team" : "blue" }
],

// List of discs:
"discs" : [
	// Left posts:
	{ "pos" : [-400,  75], "trait" : "goalPost" },
	{ "pos" : [-400, -75], "trait" : "goalPost" },

	// Right posts:
	{ "pos" : [ 400,  75], "trait" : "goalPost" },
	{ "pos" : [ 400, -75], "trait" : "goalPost" }
],

// List of planes:
"planes" : [
	{ "normal" : [0, 1], "dist" : -200, "trait" : "ballArea" }, // Top ball area wall.
	{ "normal" : [0,-1], "dist" : -200, "trait" : "ballArea" }, // Bottom ball area wall.

	// Player bounds:
	{ "normal" : [ 0, 1], "dist" : -250, "bCoef" : 0.1 }, // Top wall.
	{ "normal" : [ 0,-1], "dist" : -250, "bCoef" : 0.1 }, // Bottom wall.
	{ "normal" : [ 1, 0], "dist" : -450, "bCoef" : 0.1 }, // Left wall.
	{ "normal" : [-1, 0], "dist" : -450, "bCoef" : 0.1 }  // Right wall.
],

// List of traits:
"traits" : {
	"ballArea" : { "vis" : false, "bCoef" : 1, "cMask" : ["ball"] },
	"goalPost" : { "radius" : 8, "invMass" : 0, "bCoef" : 0.5 },
	"goalNet" : { "vis" : true, "bCoef" : 0.1, "cMask" : ["ball"], "curve" : 110 }, 
	"kickOffBarrier" : { "vis" : false, "bCoef" : 0.1, "cGroup" : ["redKO", "blueKO"], "cMask" : ["red", "blue"] }
}
}

image.png 

Opublikowano

Kurczę, przecież obok /prawie/ każdej linjki kodu masz komentarz. Tutaj nawet nie jest potrzebna znajomość żadnego języka programowania, tylko umiejętność czytania po angielsku (Google Translate?).

  • 4 tygodnie później...

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...