ambiera home ambiera home

Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name:  Password:    
Ambiera Forum > CopperCube > Programming and Scripting
Using Object-Oriented Javascript with CopperCube
Author Text

trinimac
Registered User
Quote
2018-01-10 07:08:19

I'm interested in making a game, which is a bit like "Pokemon with Superheroes."

For those with the background I'd like to set up the powers in an object-oriented way, that are allocated to the player and enemies in the game (OOP type set up), that way the code can be reused and allocated differently for each actor (i.e. regeneration).

Is it possible to do this in CopperCube 5? If so how do I set it up? I assume I use prototyping but i'm not sure how to integrate it into the basic game.

The graphics and the "game build" are actually secondary to me building up the rpg system, so my approach is probably the opposite way around to most approaching CopperCube. Thanks.


niko
Moderator
Quote
2018-01-11 08:04:47

Basically everything is an object in JavaScript, you just need a way to come up with a system to use it, that you like. I'm personally usually writing classes / objects like this:


// this is the constructor
NameOfMyClass = function(param1, param2, param3)
{
// do initialization stuff here
}

NameOfMyClass.prototype = new NameOftheBaseClass();

NameOfMyClass.prototype.AMemberFunction = function()
{
// implementation of the member function here
}


That way you can easily derive stuff from other classes, and create objects easily using the usual

var obj = new NameOfMyClass(x,y,z);


notation.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Inter?ational" (you are not logged in)


Text:

 

  

Forum Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   





Software: Ambiera Light Forum. © 2008-2018 Nikolaus Gebhardt, Ambiera e.U.