Generating playable objects
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Generating playable objects
I'm trying to make a game where you first have a playable object, then if you press a button, a new playable object will be generated and the first object won't be playable anymore. Does anyone know how to do this generation?
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Generating playable objects
I have a very (very, very) bad implementation of this in netris. Basically I set an 'active' flag. But.. your question, what do you mean by "generation"?
Re: Generating playable objects
Ok, what I mean with generation is that a new object (body) will be made when pushing a button.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Generating playable objects
Okay, but that depends on the object you're trying to create. I had a few possibilities and just used math.random to decide which one to create.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Generating playable objects
What exactly is your question?eliasaif wrote:I'm trying to make a game where you first have a playable object, then if you press a button, a new playable object will be generated and the first object won't be playable anymore. Does anyone know how to do this generation?
How to generate the object? Exactly the same way you create all other objects.
How to have a different playable object? Bartbes answered that one already.
Help us help you: attach a .love.
Re: Generating playable objects
The question is how I can make new objects by pressing a button. I'm pretty new to this.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Generating playable objects
Alright. Well, there are a number of ways to do that, most of which involve tables. Do you have any code written for this game?eliasaif wrote:The question is how I can make new objects by pressing a button. I'm pretty new to this.
An example:
If you have "class" PlayerObject, and in load(), you called
Code: Select all
player = PlayerObject:new()
Code: Select all
oldplayer = player
player = PlayerObject:new()
Help us help you: attach a .love.
Re: Generating playable objects
Ok, i attached the code.
- Attachments
-
- game.love
- (8.37 KiB) Downloaded 110 times
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Generating playable objects
I made an example how it could be done. If you want to be able to make multiple new player objects, you might want to put the old player objects in a table, instead of this:
- Attachments
-
- main.lua
- (2.83 KiB) Downloaded 121 times
Help us help you: attach a .love.
Re: Generating playable objects
That's exactly what I meant! But how do I get the old objects to still have an image?
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 71 guests