Creating a 3D effect with GDevelop?

A last question: do you know how to work with x,y,z coordinates? What do they means?

Hi @Tarsio,
Thanks for your quick reply. The game will have random stuff in the bookshelves that the player is supposed to pick with an animated hand. I am planning on creating most of the graphics next week. There will be bookshelves on both sides of the floor and I guess I will go for one or maybe two items per book shelf, increasing the speed over time. Different items give different amount of points.

Yes, I know about X, Y and Z coordinates and where they point. I have managed roughly to place the shelves pretty much by guessing where to change values. This is what it looks like right now:

As you can see the shelves aren’t aligned with the floor but I am getting closer :slight_smile:

Thanks

//Farre

Here is my code right now. For some unknown reason the pointer for the shelves has to move slower than the pointer for the floor. I also have been messing around with the coeff to change the scale. I don’t know if that is the right approach.

Ok, so you have just the shelves and the floor.

The speed is not the same since you are moving the bookshelves using the x position, and the perspective is not the same.

Here is my preview https://s3-eu-west-1.amazonaws.com/gd-games/game-291665f2-ec7c-4484-8dd3-e57a4a4573ba/index.html I added th origin in green.

Here is my code

You need to change the heigth and the coefficient in X position in order to follow perspective lines starting from the origin.
Also, i edited the origin point of the shelves sprite in order to make the alignement easier!

Hi,
Thanks! It would be great if you could show all of your code, since I have a few questions regarding your example.

  1. Are you using the same pointer both for the floor and for the shelves? If not, does the pointer of the shelf move along the x axis or the y axis in your example? As you noticed, In my case I have two pointers moving in two different directions. Is that a bad idea?

  2. Are you using the same coeff and i for both the floor and the shelves?

By the way, I guess, in the final version, I will have something moving on top of the scene also, such as lamps or a ceiling of some kind.

//Farre

No, it is the same pointer, on the y axis, the same coeff and the same i ( but I create a shelf just for even i) It must be, since the spee is the same.
But I changed the origin of the sprites, at the bottom of it, for making things easier

Hi again,
I changed my code to look as close to how I guess that your code looks like as possible. But my result is one single bookshelf zooming in from the upper left corner, once. Also I am wondering why you compare the first condition with -Variable(i). Wouldn’t it be enough to compare it with 1? That said, since the pointer will always be bigger than 1 as well as it will always be bigger than -Variable(i) and it is just a comparison.

image

Thanks

Farre

This is the integrality of my code:


Cattura

i is a negative number, so -Variable(i) is a positive number, bigger than 1. The aim is create a bookshelf every two floor sprites.

In your code, when you create the bookshelf, you forgot to set the id variable

1 Like

Just an idea:
Could it be easier instead of generating all these formulas to use a sprite rendering the background, and this sprite has an animation to play? If you pick those animation images wisely, you should have

  • the freedom to use whatever application or script to prepare the animation
  • the possibility to add as many ‘features’ as you like without making your gdevelop code unmanageable

I never did this kind of animation but thought an alternative approach might limit the effort of gdevelop programming…

@hiran, I first thought of that but since the shelves are going to be random with different stuff in them to catch, with different points, I guess that won’t be a perfect solution. I want to have control over the shelves and change their animation number when they are hit, to make them empty.

//Farre

@Tarsio,
Thank’s for your help. Now I am getting closer to the final graphics of the game and as you can see by following the link below, the proportions are still far from correct. I have put the final proportions of the scene as a background. I have tried to change all kinds of numbers in the code and even took a class in maths trying to learn a bit more about power series. My math teacher, who isn’t a programmer couldn’t really understand how we got those results.

https://www.posh.se/shoplifter/

Can you please help me to find what parameters I should change to get the right proportions?

Here is my code:

Thanks

Farre

Hi! You don’t need the +240 or +1740. Use just the position of the origin.
I circled the parameters you can play with

I’m a math teacher too, you need power series for finding Y coordinates, since you are taking the sum of bigger and bigger floor tiles. In any case it works, I suppose it’s enough :wink:

Hi @Tarsio,
If I remove the +240 and +1740 values the animation will start at x=0 and y=0 regardless of what values I put into the values that you have put red rings around. There must be another value to play with. For example, where is Origin created and what value does it have?

This is what it looks like when i delete +240 and +1740:

Here is my code:

Thanks

Farre

Hi,
maybe you could change the title into something as “one point 3D perspective effect with gdevelop”