Tumgik
#gdscript
omeletcat · 3 months
Text
sometimes when i find a tutorial on how to add something in my game, and the guy shows his code and its like twice as long and fancy as mine and has a bunch of other stuff i feel disappointed i my script and try and go like: its not about the size of your code its about how you use it! but then my code doesn't work...
58 notes · View notes
sodabytes · 7 months
Note
You said you programmed in Godot, right?
If I wanted to start on Godot (with some prior coding experience) should I use GDScript or C#?
sorry that i'm only answering this a million years later but i'd say get familiar with gdscript first and use c# later!! it's very easy and fast to learn, and i think you'll get a better grasp of how the engine works if you use it first. plus, thanks to being an interpreted language, it has Nifty Features like letting you edit code while the game is running and immediately see the change after saving. plus uhh i like it and it's cool
29 notes · View notes
weazeltech · 1 year
Text
Simple Audio Management in Godot
You can create a Singleton Scene with 2 Audio Stream Players, one for sound effects, the other for music, and then call it anywhere in your code like this:
Tumblr media
Then you can call it:
Tumblr media
It may look verbose, but you're supposed to use the autocomplete feature here for it to show what are the available sound effects and music in your game.
47 notes · View notes
plasticdinobitch · 6 months
Text
yk i really love coding in a continuously updating language because i'll try to find out how to do something and get 7 completely different answers and 2 people saying it isnt even possible
7 notes · View notes
bbchargegame · 6 months
Text
The most frustrating part about gamedev for me rn is being a rookie that struggles to finish his basic gameplay stuff..
I have so many fun ideas and worlds I want to work on, but I cant cuz Im still learning the roots.. :c
I will get there tho!
Tumblr media Tumblr media
9 notes · View notes
Text
First video showing some of the progress in the development of my game.
4 notes · View notes
setracsed · 1 year
Text
Tumblr media
First thing about Godot : it comes with its own scripting language. Where with Unity, I was coding in C# (and I was fine with that), for Godot I'll have to learn a new language. I'm fine with it, it seems that the syntax is close to Python.
First noticeable thing: no end of line symbol. I come from the Java ecosystem, I learned to code with .Net, it's going to be very hard not to put a semicolon ! No parenthesis around conditions, either.
4 notes · View notes
no-semicolons · 1 year
Text
These first few devlogs will be numbered with roman numerals as I have not yet started work on my actual game
Context and warning
This project is my graduation project for high school, I do have a partner for doing this, but they’re behind me on learning the engine. Imay publish the result or even keep working on it after my senior year, saying this, to people who would push for me to release my project earlier than my senior year, no. This is a school project and I will not be pushed, the school comes first.
Mario Clone
To learn Godot, my engine of choice, I have been working on multiple small projects, such as a Tarot reader, a mobile game on the Godot docs, and more recently, a Super Mario Bros. clone.
Today I will be going over:
The movement script
The bounding box and signals in Godot
My plans for this project
Movement Script
In the movement script, I may have been caught in some feature creep. The movement script has:
Side to Side movement
@export var speed = 300.0 @export var friction = 10 ... func _physic_process(delta): ... if Input.is_action_pressed("ui_right"): velocity.x += speed if Input.is_action_pressed("ui_left"): velocity.x -= speed else: velocity.x = move_toward(velocity.x, 0, friction)
The "ui_right" is set to right arrow key and D, the "ui_left" is set to left arrow key and A. When "ui_right" or "ui_left" are pressed the velocity vector (Vector2(x, y)) is incremented by speed, and when neither are pressed the move_toward function is used. The move_toward function takes the arguments “what value does it start at, what is the end value, what value is it decremented/incremented by”, in my case, the starting value is the current x velocity, the end value is 0, or standing still, and it is decremented by friction, which equals 10.
Jumping with Jump Buffering and Coyote Time
@export var jump = -400.0 ... var coyoteTimer var jumpBuffer = 0 var isJumping = false ... func _ready(): coyoteTimer = Timer.new() coyoteTimer.one_shot coyoteTimer.wait_time = 1.0 add_child(coyoteTimer) ... func _physics_process(delta): if jumpBuffer > 0: if is_on_floor(): velocity.y = jump isJumping = true jumpBuffer = 0 else: jumpBuffer -= 1 elif Input.is_action_just_pressed("ui_accept"): if is_on_floor(): velocity.y = jump isJumping = true elif not coyoteTimer.is_stopped(): velocity.y = jump isJumping = true else: jumpBuffer = 5 elif Input.is_action_just_released("ui_accept"): velocity.y = max(velocity.y, jump)
Let’s look through this line by line, starting with the variable jump, why is it negative if you want to go up, well in Godot, the vector graph is mirrored over the x axis so -y is up and +y is down. The other variables apply to jump buffering and coyote time. I haven’t told you about jump buffering and coyote time yet have I? well, they’re both fairly simple features that make the game feel smoother and more responsive. Jump buffering makes it so that if you hit the jump button ("ui_accept") and you're not quite on the ground, you'll jump when you land. Coyote time is named after Wile E. Coyote and makes it so that if you jump just after leaving a ledge, when it seems like you'd still be able to jump, you can. The _ready() function is the first thing to run, as it runs on startup, this one sets up the coyote timer The _physics_process() function runs every physics frame , yes, there are even more kinds of framerate! This first if statement checks to see if the jump buffering frames are still active. If they are, and the player is on the floor, then the player jumps, sets isJumping to true and sets the buffer frames to 0. if is_on_floor() is false, then the code decrements jumpBuffer by 1. If there aren't any buffer frames, it checks if "ui_accept" was pressed, if so, it checks if is_on_floor() is true, if so the player jumps, else if the coyoteTimer is active, and if so, the player jumps, else, it activates the jump buffer frames. I'm not entirely sure what that last elif statement does , it probably just jumps.
Bounding Box and Signals in Godot
Signal are an incredibly powerful tool when used correctly, "Signal up, call down" is a saying in Godot that helps to make organized code . Signals can connect nodes to trigger things, but they can be ignored, which helps for reusablity.
func _on_bound_body_entered(): get_tree().reload_current_scene()
The _on_bound_body_entered() function checks if a phyics body has entered the bounding walls. the get_tree().reload_current_scene() reloads the level.
Future Plans
I hope to finish world one by the end of this week, but we'll see when we get there, and hopefully by around the end of january, me and my partner can start working on the actual game.
TCHÜSS
2 notes · View notes
livelygold · 3 months
Text
My first project in Godot ✨
1 note · View note
omeletcat · 4 months
Text
So i know i havent been posting as much as i wanted too, but that is because after ages of procrastinating i FINALLY!!! started learning programming, i'm going to use godot engine to program and i'm currently learning gdscript with Gdquest! i'm around lesson 20? i think so it won't be long until i finish it, after that il follow some random 11 hour tutorial and based on that il start on Howlbury tales!!! i honestly won't even start this year lol. also i really should make 1 single long ass post explaining and telling what the game will be about and like.. info about it? i've only been posting random character sprites and pixel art lol.
20 notes · View notes
20mice · 5 months
Text
Tumblr media
Godot 4.0 hack for easy vaargs/variadic functions
(had to make a correction, original code was broken) I wanted to make a script to print out all my nonsense signals. I couldn't figure out a way to do that sensibly, so here's a kind of Faustian hack. I couldn't get the code in here formatted nicely, so here it is in a big heap: func _ready(): connect_signals()
#this is of course an extremely silly way to do this
func print_signal(a='~',b='~',c='~',d='~',e='~',f='~',g='~',h='~',i='~',j='~'): var output = '' var last = '' for x in [a,b,c,d,e,f,g,h,i,j]: if not x is String or x != '~': # hopefully we're not using '~' much output += last last = str(x) set_text('%s : %s\n%s' % [last, output, text])
func connect_signals(): # we could use unbind if print_signal had less args, but that would lose information #if make_storage_connection: Events.make_storage_connection.connect(print_signal.unbind(3)) if make_storage_connection: Events.make_storage_connection.connect(print_signal.bind('mk_strg_con'))
0 notes
weazeltech · 1 year
Text
Resizable Custom Pixel Cursor in Godot 4
Here’s how you get a resizeable pixel cursor in godot 4 (if you have something more efficient please send it my way I know this isn’t the best code for this)
Tumblr media
Here it is at work
Tumblr media
8 notes · View notes
poswojsku-blog · 6 months
Video
youtube
How to make a 2D game Godot 4.x GDScript part 1 Introduction
1 note · View note
dnallohleoj · 6 months
Text
Gdscript is making me more nervous than everything being a Scene what do you MEAN there's no semicolons?
0 notes
swarwebsite · 6 months
Text
Tumblr media
اختبر فهمك للمتغيرات في لغة GDScript من خلال اختبار بسيط.
يمكنك الخضوع للإختبار من خلال الضغط هنا.
1 note · View note
roboticastudios · 1 year
Text
Coding a level select menu.
I want to preface that I am not the best at anything, especially programming, but I thought I would share how I handle level select menus in TeTriDi, where I have menu screens that let you select between 20 different levels. Hopefully these kinds of posts are helpful to other indie devs out there, and still interesting for the non-indie-devs as well! And if you have improvements to share, I'm all ears, I'm still learning!
Here is a screenshot of what the menu looks like:
Tumblr media
TeTriDi is made in the Godot Engine v3.5, with which I use GDScript.
Tumblr media
First of all, the setup variables. I prefer creating onready vars for direct node access, this is handy in case you later change the node tree structure, all you would have to do is update these parameters at the top of the code.
Tumblr media
In Godot, the _ready() function is run during initialization of the script, so in this case I use it to initiate the UI focus grabbing onto the first button, which represents the first level, and to call for displaying the current record of that level.
The for loop here is for connecting all of the buttons pressed signals via code instead of through the nodes GUI settings, this is important for the way I'm doing this menu.
Tumblr media
Under the _process function, which runs constantly, I set the selector position to the button that currently has focus, with a position offset to make the selector sprite align properly. This does require that you set the focus options on the button nodes focus properties.
On each button pressed I have set the transition type and new scene directory before beginning the transition.
Under _unhandled_input I have the cursor move sound effect and current_record functions so that they run anytime the player hits the any buttons.
Tumblr media
The current_record function gets the level number, score, and text from my global script.
And that's it! If you have any questions or feedback feel free to comment or reach out. Thanks for reading.
0 notes