Godot 4 Platformer ट्यूटोरियल: Coyote Time, Jump Buffer, Game Feel

Godot 4.6 में Pop Jump gameplay: pastel आसमान के नीचे candy-रंग के platforms पर एक गुलाबी jelly-blob hero, star coins और coin counter वाला HUD
तैयार गेम, Pop Jump: 5,000 px का candy level, 18 star coins, 4 gumdrop enemies और एक goal flag। स्क्रीन पर सब कुछ कोड से draw किया गया है।

1. हम क्या बना रहे हैं

किसी platformer की सफलता इस पर टिकी होती है कि jump कैसा महसूस होता है। Godot 4 में physics वाला हिस्सा आसान है — भारी काम CharacterBody2D और move_and_slide() कर देते हैं। एक अकड़े हुए prototype और खेलने में मज़ेदार गेम के बीच का फ़र्क़ कुछ छोटी-छोटी tricks से आता है: coyote time, jump buffer, variable jump height, तेज़ गिरावट, और थोड़ा-सा squash and stretch।

यह ट्यूटोरियल Godot 4.6 के लिए GDScript 2.0 में बने एक पूरे, चलने वाले platformer को step-by-step समझाता है। हर अंश असली प्रोजेक्ट की scripts (player.gd, main.gd, enemy.gd आदि) से कॉपी किया गया है; वेब के लिए सिर्फ़ indentation बदला गया है। गेम Pop Jump में ये चीज़ें हैं:

  • acceleration, friction और अलग air control वाला एक squishy blob hero;
  • माफ़ करने वाले jumps: coyote time, jump buffer और variable height;
  • land होने पर squash, उछलने पर stretch;
  • सादे data के रूप में परिभाषित level — Rect2 और Vector2 के arrays;
  • 18 घूमते star coins, 4 patrolling enemies जिन्हें आप stomp कर सकते हैं;
  • गिरने और चोट लगने पर respawn, एक goal flag और win screen;
  • player का पीछा करने वाला एक smooth camera।

पूरा player controller लगभग 45 lines का एक _physics_process() है। ये रहे उसके tuning constants — वे numbers जिन्हें आप सबसे ज़्यादा बदलेंगे:

player.gd — constants
const SPEED := 360.0
const ACCEL := 2800.0
const FRICTION := 2400.0
const AIR_ACCEL := 1800.0
const JUMP_VELOCITY := -820.0
const GRAVITY := 1900.0
const MAX_FALL := 1400.0
const COYOTE_TIME := 0.1
const JUMP_BUFFER := 0.12

सभी values pixels और seconds में हैं। याद रखें कि Godot 2D में positive Y नीचे की ओर होता है, इसलिए jump एक negative velocity है।

2. Scenes और input actions

Scene tree बहुत छोटा है। Main (main.gd वाला एक Node2D) में background के लिए layer -1 पर एक SkyLayer CanvasLayer, runtime पर भरा जाने वाला एक खाली Level node, Player, और दो labels वाला एक HUD CanvasLayer है। Player एक CharacterBody2D है जिसमें 36×40 का RectangleShape2D और एक Camera2D child है। Window 1280×720 है।

तीन input actions हैं: move_left (A, Left), move_right (D, Right) और jump (Space, W, Up)। एक बात जो कॉपी करने लायक़ है: final project.godot में हर key event physical key से नहीं, बल्कि keycode से bind है (physical_keycode को 0 पर छोड़ा गया है)। पहला version AI के simulated key presses पर प्रतिक्रिया नहीं दे रहा था, और controls को फिर से bind करना ही उसका fix था (ज़्यादा जानकारी AI के साथ इसे बनाना में)। अगर आपकी अपनी input testing या automation ऐसे key events भेजती है जो actions trigger नहीं करते, तो जाँचें कि आपके actions इन दोनों में से किससे match करते हैं।

3. CharacterBody2D movement: acceleration, friction, air control

Platformer movement का शुरुआती version velocity.x = dir * SPEED है। यह काम करता है, लेकिन character तुरंत चलता और तुरंत रुकता है, जो robotic लगता है। इसके बजाय, target speed की ओर हर सेकंड एक तय मात्रा से बढ़िए:

player.gd — horizontal movement
    var dir := Input.get_axis("move_left", "move_right")
    var accel := ACCEL if is_on_floor() else AIR_ACCEL
    if dir != 0.0:
        velocity.x = move_toward(velocity.x, dir * SPEED, accel * delta)
        facing = signf(dir)
    else:
        velocity.x = move_toward(velocity.x, 0.0, FRICTION * delta)

    move_and_slide()

यहाँ तीन चीज़ें हो रही हैं:

  • Acceleration। ACCEL = 2800 और SPEED = 360 के साथ hero लगभग 0.13 s में पूरी speed पर पहुँच जाता है — फुर्तीला, लेकिन तुरंत नहीं।
  • Friction। कोई input न होने पर speed 2400 px/s² की दर से शून्य की ओर घटती है, इसलिए hero एकदम रुकने के बजाय कुछ pixels फिसलता है।
  • Air control। हवा में hero AIR_ACCEL = 1800 इस्तेमाल करता है, जो ज़मीनी acceleration का लगभग दो-तिहाई है। आप jump को अब भी मोड़ सकते हैं, लेकिन पलक झपकते दिशा नहीं पलट सकते। भारी, ज़्यादा प्रतिबद्ध jump के लिए इसे घटाइए; हल्के, तैरते jump के लिए बढ़ाइए।

Input.get_axis() keys के लिए -1, 0 या 1 लौटाता है (analog stick के लिए बीच की कोई भी value), और facing आख़िरी दिशा याद रखता है ताकि रुकने पर भी आँखें सही ओर देखती रहें। ध्यान दें कि कोई key न दबी हो तो friction हवा में भी लगता है — jump के बीच key छोड़ने पर hero धीरे-धीरे रुक जाता है।

4. तेज़ गिरावट वाली gravity

असली gravity एक symmetric arc बनाती है: आप ठीक उतनी ही धीमी गति से ऊपर जाते हैं जितनी से गिरते हैं। Platformers लगभग हमेशा यहाँ cheat करते हैं और ऊपर जाने से तेज़ गिरते हैं, जिससे jumps वज़नदार लगते हैं और कम तैरते हुए। यह प्रोजेक्ट इसे एक multiplier से करता है:

player.gd — gravity और coyote timer
    if is_on_floor():
        coyote = COYOTE_TIME
    else:
        coyote -= delta
        var g := GRAVITY * (1.5 if velocity.y > 0.0 else 1.0)
        velocity.y = minf(velocity.y + g * delta, MAX_FALL)

ऊपर जाते समय (velocity.y negative) gravity 1900 px/s² होती है; hero के arc के शिखर को पार करते ही यह 2850 हो जाती है। minf(..., MAX_FALL) गिरने की speed को 1400 px/s (terminal velocity) पर सीमित करता है, ताकि लंबी गिरावट भी पढ़ने में आसान रहे और hero एक physics frame में (60 ticks प्रति सेकंड पर) लगभग 23 px से ज़्यादा कभी न चले, जो 30-px मोटे ledges से कम है। यही if coyote timer को भी चलाता है, जो अगला विषय है।

5. Coyote time, jump buffer और variable jump height

इन्हीं तीन tricks की वजह से खिलाड़ी किसी platformer को “tight” कहते हैं। हर एक बस कुछ lines का है।

Coyote time

इसका नाम उस cartoon coyote के नाम पर है जो चट्टान से आगे दौड़ जाता है और तभी गिरता है जब उसे इसका एहसास होता है। खिलाड़ी जितना सोचते हैं उससे कहीं ज़्यादा बार किनारा छोड़ने के कुछ frames बाद jump दबाते हैं। Coyote time के बिना वह press कुछ नहीं करता और लगता है जैसे गेम ने input निगल लिया। ऊपर वाला अंश ज़मीन पर हर frame coyote को 0.1 s पर reset करता है और हवा में उसे घटाता है। फिर jump check “क्या मैं अभी ज़मीन पर हूँ?” के बजाय “क्या मैं पिछले 0.1 s के भीतर ज़मीन पर था?” पूछता है।

Jump buffer

इसका उलटा रूप: खिलाड़ी land होने से कुछ frames पहले भी jump दबाते हैं। Jump buffer उस press को 0.12 s तक याद रखता है, और jump जैसे ही वैध होता है, fire हो जाता है:

player.gd — jump buffer, jump, variable height
    if Input.is_action_just_pressed("jump"):
        buffer = JUMP_BUFFER
    else:
        buffer -= delta

    if buffer > 0.0 and coyote > 0.0:
        velocity.y = JUMP_VELOCITY
        buffer = 0.0
        coyote = 0.0
        squash = Vector2(0.65, 1.4)

    if Input.is_action_just_released("jump") and velocity.y < 0.0:
        velocity.y *= 0.5

Jump की शर्त buffer > 0.0 and coyote > 0.0 एक ही line में दोनों tricks को जोड़ती है: हाल का press और हाल का ज़मीनी संपर्क। Jump के बाद दोनों timers को शून्य करना ज़रूरी है। अगर आप सिर्फ़ buffer साफ़ करते, तो अभी भी positive coyote timer कुछ frames बाद दूसरे press को हवा में फिर से jump करने दे सकता था — एक अनचाहा double jump।

Variable jump height

आख़िरी दो lines खिलाड़ी को ऊँचाई पर नियंत्रण देती हैं। हर jump एक ही -820 px/s से शुरू होता है। अगर hero के ऊपर जाते समय button छोड़ दिया जाए, तो ऊपर की speed आधी कर दी जाती है, जिससे jump जल्दी ख़त्म हो जाता है। हल्का tap किसी enemy के ऊपर से छोटी छलाँग है; दबाए रखने पर ऊँचे platform तक पूरा jump मिलता है। velocity.y < 0.0 check देर से छोड़े गए button को गिरावट पर असर डालने से रोकता है।

Tuning टिप

एक बार में एक ही number बदलिए और एक मिनट खेलकर देखिए। JUMP_VELOCITY और GRAVITY मिलकर jump की ऊँचाई और हवा में रहने का समय तय करते हैं; 1.5 वाला fall multiplier वज़न तय करता है; 0.5 वाला release cut तय करता है कि tap कितना छोटा होगा। Coyote time और buffer लगभग 0.08 से 0.15 s के बीच सबसे अच्छे लगते हैं — माफ़ करने के लिए काफ़ी लंबे, और इतने छोटे कि किसी को पता न चले।

6. Squash and stretch

Squash and stretch game feel को बेहतर बनाने का सबसे सस्ता तरीका है। Hero के पास एक squash vector है जो सामान्यतः Vector2.ONE होता है। Events उसे एक चरम value पर धकेल देते हैं, और हर frame वह धीरे-धीरे वापस आ जाता है:

  • उछलना (take-off): squash = Vector2(0.65, 1.4) — लंबा और पतला (ऊपर के jump code में)।
  • Land होना: squash = Vector2(1.4, 0.65) — चौड़ा और चपटा।
  • Stomp bounce: Vector2(0.7, 1.3); respawn: Vector2(1.5, 0.5)।
player.gd — landing detection और recovery
    if is_on_floor() and not was_on_floor:
        squash = Vector2(1.4, 0.65)
    was_on_floor = is_on_floor()
    squash = squash.lerp(Vector2.ONE, 1.0 - exp(-14.0 * delta))

Landing का पता is_on_floor() की तुलना पिछले frame की value से करके लगाया जाता है। Recovery में 0.2 जैसे तय factor के बजाय 1.0 - exp(-14.0 * delta) के साथ lerp इस्तेमाल होता है; यह रूप किसी भी frame rate पर recovery की एक जैसी speed देता है।

सिर्फ़ visuals scale होते हैं — collision shape कभी नहीं बदलता, इसलिए squash hero को दीवारों में नहीं धकेल सकता। Hero _draw() में draw होता है, और trick यह है कि center के बजाय पैरों के चारों ओर scale किया जाए, ताकि दबा हुआ blob ज़मीन पर टिका रहे। Collision box 40 px ऊँचा और centered है, इसलिए पैर y = 20 पर हैं:

player.gd — _draw() transform
    # Scale around the feet so squash keeps the blob planted on the ground.
    var run_wobble := sin(t * 18.0) * 0.05 * absf(velocity.x) / SPEED if is_on_floor() else 0.0
    var s := squash + Vector2(-run_wobble, run_wobble)
    draw_set_transform(Vector2(0, 20.0 * (1.0 - s.y)), 0.0, s)

एक छोटा bonus: run_wobble ज़मीन पर दौड़ते समय speed के अनुपात में एक हल्का squash cycle जोड़ता है, जिससे blob चलते हुए थिरकता है। आँखें भी facing और velocity.y का इस्तेमाल करके चलने की दिशा में देखती हैं। चूँकि _draw() तभी चलता है जब उसे कहा जाए, _physics_process() के अंत में queue_redraw() है।

7. Rect2 data से level बनाना

TileMap के बजाय level main.gd में तीन constant arrays है। इससे वह पढ़ने में आसान, बदलने में आसान, और AI (या आपके) लिए text के रूप में edit करने में आसान रहता है:

main.gd — level data (अंश)
# Rect2(x, top_y, width, height)
const PLATFORMS := [
    Rect2(-200, 600, 1400, 200),
    Rect2(1350, 600, 900, 200),
    Rect2(2400, 600, 1250, 200),
    Rect2(3820, 600, 1400, 200),
    Rect2(480, 470, 200, 30),
    Rect2(780, 370, 180, 30),
    # ...
]

# [x, left, right]
const ENEMIES := [
    [900, 750, 1150],
    [1800, 1450, 2150],
    [2900, 2500, 3550],
    [4200, 3950, 4700],
]

चार बड़े rectangles ज़मीन हैं, जिनके बीच गिरने के लिए gaps हैं; 30-px ऊँचे rectangles तैरते ledges हैं। COINS 18 Vector2 positions की एक सूची है। _ready() में हर entry एक node बन जाती है:

main.gd — _ready() का platform loop
    for i in PLATFORMS.size():
        var r: Rect2 = PLATFORMS[i]
        var p := PlatformScript.new()
        p.size = r.size
        p.color = Color(PALETTE[i % PALETTE.size()])
        p.position = r.position
        level.add_child(p)

PlatformScript दरअसल preload("res://scripts/platform.gd") है, एक script जो extends StaticBody2D करती है। किसी script पर .new() call करने से उस script वाला node बन जाता है, किसी scene file की ज़रूरत नहीं। Tree में प्रवेश करते समय platform size से अपना collision shape ख़ुद बनाता है:

platform.gd — _ready()
func _ready() -> void:
    var cs := CollisionShape2D.new()
    var r := RectangleShape2D.new()
    r.size = size
    cs.shape = r
    cs.position = size / 2.0
    add_child(cs)

RectangleShape2D अपने node पर centered होता है, इसलिए shape को उसके आधे size से offset किया जाता है, ताकि वह उस Rect2 से मेल खाए जिसकी position उसका top-left कोना है। फिर platform draw_style_box() और एक गोल कोनों वाले StyleBoxFlat से ख़ुद को draw करता है, ऊपर एक हल्की “frosting” पट्टी के साथ। अंत में, main.gd x = -220 और x = 5240 पर दो अदृश्य 40×2000 StaticBody2D दीवारें जोड़ता है ताकि player किनारों से level के बाहर न जा सके।

8. Area2D से coins

Coins 18-px CircleShape2D वाले Area2D nodes हैं। Area2D movement को रोके बिना overlaps का पता लगाता है, जो किसी pickup के लिए ठीक वही है जिसकी ज़रूरत है। Player अपने _ready() में ख़ुद को "player" group में डालता है, और coin उसी की जाँच करता है:

coin.gd — pickup
func _on_body_entered(body: Node) -> void:
    if taken or not body.is_in_group("player"):
        return
    taken = true
    collected.emit()
    var tw := create_tween()
    tw.tween_property(self, "scale", Vector2(2.2, 2.2), 0.18)
    tw.parallel().tween_property(self, "modulate:a", 0.0, 0.18)
    tw.tween_callback(queue_free)

taken flag coin को दो बार गिने जाने से रोकता है, जब तक उसका 0.18 s का pop-and-fade tween चल रहा हो। main.gd collected signal को c.collected.connect(_on_coin.bind(c)) से connect करता है; handler गिनती बढ़ाता है, एक छोटा burst effect spawn करता है और HUD label का scale 1.3 तक बढ़ाकर tween से वापस लाता है। Coin का घूमना असल में absf(cos(t * 2.5)) से उसकी drawing को horizontally दबाकर नक़ली तौर पर दिखाया गया है।

9. Patrolling enemies: stomp करें या चोट खाएँ

Enemies भी Area2D nodes हैं — उन्हें physics की ज़रूरत नहीं, बस एक position चाहिए जो left और right के बीच आगे-पीछे चलती रहे:

enemy.gd — patrol
    t += delta
    position.x += dir * speed * delta
    if position.x > right:
        dir = -1.0
    elif position.x < left:
        dir = 1.0

दिलचस्प हिस्सा यह तय करना है कि संपर्क होने पर player ने enemy को stomp किया या उससे टकरा गया:

enemy.gd — stomp या hurt
func _on_body_entered(body: Node) -> void:
    if dead or not body.is_in_group("player"):
        return
    if body.velocity.y > 0.0 and body.global_position.y < global_position.y - 26.0:
        dead = true
        body.bounce()
        stomped.emit()
        var tw := create_tween()
        tw.tween_property(self, "scale", Vector2(1.6, 0.2), 0.12)
        tw.tween_property(self, "modulate:a", 0.0, 0.2)
        tw.tween_callback(queue_free)
    else:
        body.hurt()

Stomp के लिए दो चीज़ें चाहिए: player गिर रहा हो (velocity.y > 0.0) और player का center enemy से 26 px से ज़्यादा ऊपर हो। Enemy का origin उसके पैरों पर है, इसलिए यह threshold मोटे तौर पर उसके शरीर का ऊपरी हिस्सा है। दोनों की जाँच से वह player enemy को नहीं मार पाता जो नीचे से ऊपर की ओर कूदकर उससे टकराता है। Stomp enemy को fade होने से पहले चपटा (scale 1.6×0.2) कर देता है, और player का bounce() call करता है:

player.gd — bounce() और hurt()
func bounce() -> void:
    velocity.y = JUMP_VELOCITY * 0.75
    squash = Vector2(0.7, 1.3)


func hurt() -> void:
    if invuln > 0.0:
        return
    die()

Bounce सामान्य jump का 75% है, जिससे लगातार stomps करना मज़ेदार लगता है। कोई भी दूसरा संपर्क hurt() call करता है, जो एक छोटी invulnerability window का ध्यान रखता है।

10. गिरना, respawn, goal और camera

Gap में गिरने की जाँच _physics_process() के अंत में if global_position.y > 1100.0: die() से होती है। गिरना और enemy से चोट, दोनों एक ही function पर ख़त्म होते हैं:

player.gd — die()
func die() -> void:
    global_position = spawn_point
    velocity = Vector2.ZERO
    invuln = 1.2
    squash = Vector2(1.5, 0.5)
    died.emit()

न lives हैं, न game over: hero _ready() में सहेजे गए spawn_point पर वापस चला जाता है, इकट्ठा किए गए coins इकट्ठा ही रहते हैं, और 1.2 सेकंड तक वह invulnerable रहता है। _draw() इसे एक-एक frame छोड़कर जल्दी return करके (int(t * 20.0) % 2 == 0) दिखाता है — classic blink। main.gd died को सुनता है और “Oops! Try again!” दिखाता है।

x = 5000 पर goal flag एक और Area2D है, जिसमें 40×200 का ऊँचा collision box और एक reached signal है। वहाँ पहुँचने पर main.gd player को freeze करके नतीजा दिखाता है:

main.gd — _on_goal()
func _on_goal() -> void:
    finished = true
    player.set_physics_process(false)
    player.squash = Vector2(0.6, 1.4)
    _burst(player, Color("#ff4f8b"))
    _show_message("YOU WIN!  %d / %d coins\nPress R to play again" % [coins, COINS.size()], 0.0)

Physics processing बंद करने से सारी movement रुक जाती है, लेकिन hero को अपना जश्न वाला stretch फिर भी पूरा करना चाहिए। इसलिए player.gd में एक _process() भी है जो सिर्फ़ तब squash को ease करता और redraw करता रहता है जब is_physics_processing() false हो। R दबाने पर _unhandled_input() से get_tree().reload_current_scene() call होता है।

Camera को कोई code नहीं चाहिए। यह player का एक Camera2D child है, जिसमें नरम follow के लिए position_smoothing_enabled = true और position_smoothing_speed = 7.0 है, (120, -60) का offset है ताकि आप level का आगे और ऊपर का हिस्सा ज़्यादा देख सकें, और limits (limit_left = -200, limit_right = 5220, limit_bottom = 800) हैं ताकि यह कभी level के किनारों के पार या ज़मीन के नीचे न दिखाए।

आगे क्या करें

Checkpoints (बस spawn_point को खिसकाइए), wall jump (jump की शर्त में is_on_wall() जाँचिए), jump और stomp पर sound effects, या अलग-अलग data arrays से load होने वाले कई levels। इनमें से किसी के लिए भी movement code बदलने की ज़रूरत नहीं है।

11. AI के साथ इसे बनाना

ऊपर का सब कुछ हाथ से लिखी GDScript जैसा लगता है, और आप इसे ख़ुद टाइप कर सकते हैं। लेकिन यह गेम किसी इंसान ने टाइप नहीं किया था। इसे Godot MCP Pro के ज़रिए Godot editor से जुड़े Claude Code ने इस एक prompt से बनाया (अर्थ: “मैं एक 2D platformer गेम बनाना चाहता हूँ। originality के बारे में सोचने से पहले मैं core basics बनाना चाहूँगा। कृपया इसे pop, आकर्षक graphics के साथ बनाइए।”):

I want to make a 2D platformer game. Before thinking about originality, I'd like to build the core basics first. Please make it with pop, catchy graphics.

Build में लगभग पाँच मिनट का AI काम लगा। Coyote time, jump buffer और variable jump height prompt में नहीं थे; AI ने इन्हें अपने-आप जोड़ा। चूँकि वह MCP के ज़रिए गेम चला सकता था, key presses simulate कर सकता था और screenshots ले सकता था, इसलिए उसने अपने काम को play-test भी किया और रास्ते में चार bugs ठीक किए:

  1. Simulated input से hero हिल नहीं रहा था — Claude ने controls फिर से bind किए, इसी वजह से actions keycode से bind हैं।
  2. Controls hint window दिखने से पहले ही fade हो जाता था — final गेम इसे 5 सेकंड तक दिखाता है।
  3. अभी भी चल रहे एक tween की वजह से win message आधा fade हो जाता था — _show_message() अब आख़िरी tween को msg_tween में रखता है और नया शुरू करने से पहले msg_tween.kill() call करता है।
  4. जीतने के बाद आप level के अंत से बाहर चल सकते थे — final code में goal पर player की physics बंद कर दी जाती है, और अदृश्य दीवारें level के दोनों सिरे बंद करती हैं।

पूरा build, बिना edit किए, YouTube पर देखा जा सकता है, और prompt व विवरण Pop Jump showcase पेज पर हैं। Godot MCP Pro AI assistant को 190 editor और runtime tools देता है — scenes और scripts बनाना, input actions edit करना, गेम चलाना, keys दबाना, screenshots लेना और errors पढ़ना — ताकि वह वही edit, run, look, fix loop चला सके जो आप हाथ से करते। यह आपके अपने प्रोजेक्ट्स पर भी काम करता है: उससे अपने मौजूदा player में coyote time जोड़ने को कहिए, या अपना level खेलकर यह पता लगाने को कि jump कहाँ ग़लत महसूस होता है।

12. FAQ

Godot platformer में coyote time क्या है?

Coyote time वह छोटी-सी छूट की अवधि है जिसमें खिलाड़ी के किनारे से उतर जाने के बाद भी jump काम करता है। इस ट्यूटोरियल में is_on_floor() true रहने तक हर physics frame में एक coyote timer को 0.1 सेकंड पर reset किया जाता है और हवा में वह घटता जाता है; timer शून्य से ऊपर रहने तक jump की अनुमति रहती है।

Godot 4 में jump buffer कैसे जोड़ें?

जब Input.is_action_just_pressed("jump") fire हो, एक buffer timer (यहाँ 0.12 सेकंड) set करें और हर frame उसे घटाएँ। जब भी buffer और coyote timer दोनों शून्य से ऊपर हों, jump करें और फिर दोनों को शून्य कर दें। इस तरह land होने से ठीक पहले किया गया press याद रहता है और ज़मीन पर पहले ही frame में fire होता है।

Godot में variable jump height कैसे बनाएँ?

हर jump को एक जैसी तेज़ ऊपर की velocity दें, फिर button जल्दी छोड़े जाने पर उसे काट दें: अगर Input.is_action_just_released("jump") हो और velocity.y अभी भी negative हो (ऊपर जा रहा हो), तो velocity.y को 0.5 से गुणा करें। हल्का tap छोटी छलाँग देता है और button दबाए रखने पर पूरा jump मिलता है।

क्या इस platformer के लिए sprites या TileMap चाहिए?

नहीं। Hero, platforms, coins, enemies, goal flag और आसमान सब _draw() में draw होते हैं, और level Rect2 values की एक सूची है जो runtime पर StaticBody2D platforms बन जाती है। बाद में आप movement code बदले बिना Sprite2D art या TileMapLayer लगा सकते हैं।

AI से अपना Godot गेम बनवाइए और play-test करवाइए

Godot MCP Pro, Claude Code, Cursor, Cline और दूसरे AI assistants को 190 tools के साथ Godot 4 editor से जोड़ता है: scenes बनाइए, scripts लिखिए, गेम चलाइए, input simulate कीजिए और जो टूटे उसे ठीक कीजिए।

create_script set_input_action play_scene simulate_key get_game_screenshot
Godot MCP Pro पाएँ — $15

एक बार की ख़रीद · आजीवन updates · pricing का विवरण देखें