# How can I create objects to make this work? (Spaceships)

**URL:** <https://discourse.processing.org/t/how-can-i-create-objects-to-make-this-work-spaceships/32017>\
**Category:** Coding Questions\
**Created:** [August 30, 2021, 10:33pm UTC](https://discourse.processing.org/t/how-can-i-create-objects-to-make-this-work-spaceships/32017 "2021-08-30T22:33:59Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [September 2, 2021, 9:23am UTC](https://discourse.processing.org/t/how-can-i-create-objects-to-make-this-work-spaceships/32017/2 "2021-09-02T09:23:39Z")

</div>

Hi @lucaswoah,

Can you please format your code by using the `</>` button when editing a message or use triple backticks like this: ```code``` → `code`?

> [@lucaswoah](#):
>
> I tried creating a “Spaceship” class and then spaceship1, spaceship2, etc as new objects from that class, but when I wrote spaceship1.move();, for example, every spaceship moved instead of just that one. Does anyone have an idea of how to solve this? Thank you very much!

You were on the right track! What you need is classes and objects in order for your spaceships to have their own data (position, lights, size…) and be able to do actions on them.

You can check an old post I did on the subject, it should be pretty straightforward to implement!

> [@Problems with my mini game](https://discourse.processing.org/t/problems-with-my-mini-game/21949/2):
>
> Hi, Welcome to the community! slight_smile Before trying to solve your problem, you are facing a well known problem where the structure of your code is actually describing [object oriented programming](https://en.wikipedia.org/wiki/Object-oriented_programming) : So object oriented programming is a way to structure your code by using objects to model the data that your are manipulating. In this special case, your are creating Balls, and a Ball is described as : a position (x and y coordinates on the screen) a speed (described as a vector, xDir and y…

Also a recent post by @GoToLoop :

> [@Individualize functions in P5.js](https://discourse.processing.org/t/individualize-functions-in-p5-js/32051/3):
>
> Although written for Processing’s Java Mode these 2 OOP articles can be easily applied to any Processing flavor: [forum.Processing.org/two/discussion/8082/from-several-variables-to-arrays.html](http://forum.Processing.org/two/discussion/8082/from-several-variables-to-arrays.html)[forum.Processing.org/two/discussion/8081/from-several-arrays-to-classes.html](http://forum.Processing.org/two/discussion/8081/from-several-arrays-to-classes.html) This is how we create classes in JS btW:

---

_[View the full topic](https://discourse.processing.org/t/how-can-i-create-objects-to-make-this-work-spaceships/32017)._
