The line var i = card_list(0)
is incorrect. Based on the rest of the code, card_list
is an array, not a function. Assuming you want to get the 1st element of the array, you should replace that line with var i = card_list[0]
.
Aanomalocaris
- Dec 26, 2018
- Joined Dec 23, 2018
- 0 best answers
- Edited
Tiles are based on a grid, but any collision shapes you assign to an individual tile is based on pixels. Collision is determined as follows: if any pixel of one collision shape touches any pixel of another collision shape, they're considered to be touching. Movement is also pixel-based, which is why you can have a sprite overlapping multiple tiles at once. To have grid-based movement one solution would be to use GDScript to move your sprite to the center of the tile you want it to be in.
You should have some basic knowledge of linear algebra in 2-dimensional Euclidean space. It's not as complicated as it sounds, a 2d vector is just two numbers and almost all linear algebra operations are adding and multiplying the two coordinates of various vectors. There is a short introduction to vectors in the documentation but it has a lot of unnecessary information. You don't need to know the implementation details of collision, the engine handles all that for you.
Think of coordinates as distances measured off of two perpendicular rulers from a fixed reference point. In Godot and 2d computer graphics in general this is the top-left pixel of the visible area, whether it be the screen, a window, or a viewport. This is shown in the first diagram of the "Vector math" page and if you take away anything from it this should be it.
- Edited
Found this in less than a minute with a google search for "godot collision shape" Is there a way to create collision shapes based on the contour of a sprite? Note: the question specifies Godot 2.1.2 but the first answer is for Godot 3
- Edited
That example involves at least three sprites that I can see: the player's head and arm are two sprites that always look at the mouse, and the player's body does not look at anything but flips when the mouse is to the left of the player.
You can probably do this without checking the angle; just check if the mouse coordinate is to the left of the player, assuming the player sprite faces right by default. If you were to code it this way it might look something like this (I did not run this code):
extends Sprite func _process(delta): var vert = get_global_mouse_position() var gpos = self.get_global_position() if gpos.x < vert.x: self.set_flip_h(true) vert.x = -vert.x # our sprite would be facing away from the mouse after flipping else: self.set_flip_h(false) look_at(vert)
Note that to get it to look like that video you'll have to have three sprites in your player scene. The arm and head should be rotated and flipped; you'll have to either add or subtract 180 degrees when the sprite is flipped. The body should not be rotated, just flipped. The code above works with one sprite like the head or arm. I don't know if I got the rotation handled correctly.
EDIT: fixed an issue with the y coordinate direction getting inverted
@J453Nomad said: I would really like to see a state machine implementation for character states. There are plug-ins for that, but I want to learn how to write the code and understand how it works instead of just using plugins.
Hidden in the official documentation is an FPS Tutorial that does just this for player animations. It also links to some more general tutorials on (finite) state machines. If you Google "finite state machine" you also get some pretty good conceptual overviews.
@TwistedTwigleg said: Not sure if this will help, nor if it still works with Godot 3, but apparently you can create a
_sc_
file and that will make Godot not need to read from Appdata, at least according to this closed issue on the Github repository.I found the workaround from this Reddit post, where the poster was having difficulty getting Godot to work on computer lab computers. I’m not sure if they had the same issue though, but maybe making a
_sc_
file will help?This should work on Godot 3, I just got the "Teach Yourself Godot Engine Game Development in 24 Hours" book which uses Godot 3 and it mentions it in the first chapter. Instead it creates a directory wherever you run Godot from and saves the settings/temporary files in there.
I don't fully understand what you mean by "I need at 90 degrees to make the sprite turn around." but I think I might know what the problem is. If you want to actually flip the sprite when you call set_flip_h or set_flip_v you need to pass true. Passing false will disable the sprite from flipping. So assuming you mean that if the angle is greater than 90 you want to flip the sprite, set flip_h and flip_v to true in the body of your first if statement.
Some code style things: you don't need parenthesis around the expression in your if statement. Also, you don't need to check if the angle is less than 90 since you already checked that it's greater than 90 and you can just use an else statement:
if ang >= 90: self.set_flip_h(true) self.set_flip_v(true) else: self.set_flip_h(false) self.set_flip_v(false)
The Godot editor itself runs in the engine, so it is possible. You would probably have to use GDScript for some things, I don't know how much Visual Script can do.
I've decided to quit trying to find a decent tutorial and just make a game. I've decided on a simple 2d vertical shmup with one stage that lasts forever. The longer the game is played, more difficult enemies that fire more and more bullets will appear. The goal is to survive as long as possible and get the highest score. I've done the design for player and enemy scenes and I know how I would handle a very simple enemy (i.e. fly in from outside the screen, move to a point at the screen and just keep shooting at the player). However, I'm wondering how to implement more complex movement patterns and behaviors. If all the enemy has to do is just move, then I know I could use a PathFollow2D to make the enemy move along the path and then have it freed when it goes off the screen. Is there a way to associate extra information along the points on a path that would tell the enemy to slow down/speed up or fire bullet(s) when it reaches that point? If not, how would I be able to do that?
There are some other things I've designed that I'm not too sure about either. I plan on creating a BulletSpawner scene that is able to spawn a single bullet of different types with the given velocity, direction, and possibly acceleration. Then I will create different scenes inheriting from a BulletPattern node that can handle more complex patterns, like n-way bullets, random directions, velocities, and danmaku-like patterns that can fill the screen. An enemy would then have one or more BulletPattern nodes as a child, which it interacts with by calling a method to tell it to start/stop firing. Would this be an alright way to do this? I am a complete beginner to game development and the tutorials only cover the easy stuff (like how to get a sprite moving on the screen).
I plan on giving the player a limited set of bombs they can use to clear the screen of bullets and damage enemies. To clear the screen, would the easiest way would be to put all the enemy bullets in a group and then use that to free them when the bomb is activated? I could probably handle the damage in a similar way, although I might just use an Area2D around the player that sits on the player bullet layer and use that to damage enemies.
As a software developer I'm used to reading about design patterns (not just in OOP, there are functional and procedural patterns too) and software engineering (all the steps you need to do before you put down a single line of code, as well as maintaining code). I wish there was something like this for Godot and game development in general.
Hello, I am an experienced developer (mostly Python for machine learning nowadays, but I've done C, C++, Java, Javascript, assembly and BASIC in the past) completely new to game development. I have absolutely no game development experience and the main stumbling block to me being able to make a game is a complete lack of any kind of artistic or musical talent. I even fail at making "programmer art." Luckily it seems like there are more free (i.e. permissively licensed) resources floating around the Internet these days so I might actually stand a chance. I decided to use Godot as I don't like Unity, Unreal Engine seemed like overkill as I'm primarily interested in making 2d games, and it seems to be the most efficient game engine out there that's still relatively high-level. I don't know if I picked a good time or bad time because Godot 3 is pretty new so there's not a lot of great learning material out there, but at least I don't have to unlearn the previous version.
So far I like GDScript a lot because it's similar enough to Python that I only need to look at the documentation for its syntax when I mess up instead of having to learn from scratch. I also like the scene and node architecture, which surprised me because I usually hate object-oriented programming.