0% fanden dieses Dokument nützlich (0 Abstimmungen)
235 Ansichten4 Seiten

Dino Game Script

Dino Game Script This section contains the JavaScript code that defines the behavior and logic of the Dino Game. The script handles game initialization, character movement, obstacle generation, collision detection, and scoring. You can customize the game by modifying parameters like the dino's speed, obstacle frequency, and game over conditions. Feel free to experiment with different game elements and mechanics to create your own unique Dino Game experience.

Hochgeladen von

luckyshinde2000
Copyright
© All Rights Reserved
Wir nehmen die Rechte an Inhalten ernst. Wenn Sie vermuten, dass dies Ihr Inhalt ist, beanspruchen Sie ihn hier.
Verfügbare Formate
Als DOCX, PDF, TXT herunterladen oder online auf Scribd lesen
0% fanden dieses Dokument nützlich (0 Abstimmungen)
235 Ansichten4 Seiten

Dino Game Script

Dino Game Script This section contains the JavaScript code that defines the behavior and logic of the Dino Game. The script handles game initialization, character movement, obstacle generation, collision detection, and scoring. You can customize the game by modifying parameters like the dino's speed, obstacle frequency, and game over conditions. Feel free to experiment with different game elements and mechanics to create your own unique Dino Game experience.

Hochgeladen von

luckyshinde2000
Copyright
© All Rights Reserved
Wir nehmen die Rechte an Inhalten ernst. Wenn Sie vermuten, dass dies Ihr Inhalt ist, beanspruchen Sie ihn hier.
Verfügbare Formate
Als DOCX, PDF, TXT herunterladen oder online auf Scribd lesen

DINO GAME SCRIPT.

 Dino Script (Game Object) :

using [Link];
using [Link];
using UnityEngine;

public class Script : MonoBehaviour


{
private float move;
public float playerspeed;
public float jumpspeed;
private bool isJumping;
private Rigidbody2D rb;
private Animator anim;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody2D>();
anim=GetComponent<Animator>();
}

// Update is called once per frame


void Update()
{
move = [Link]("Horizontal");
[Link] = new Vector2(move * playerspeed, [Link].y);

if(move > 0)
{
[Link] = new Vector3(0, 0, 0);
}
else if(move < 0)
{
[Link] = new Vector3(0, 180, 0);
}

if([Link]("Jump")&& !isJumping)
{
[Link](new Vector2([Link].x, jumpspeed));
isJumping = true;

}
RunAnimation();
}

private void OnCollisionEnter2D(Collision2D other)


{
if([Link]("Tiles"))
{
isJumping = false;
}
}
void RunAnimation()
{
[Link]("movement",[Link](move));
[Link]("isjumping",isJumping);
}

private void OnTriggerEnter2D(Collider2D other)


{
if([Link]("Stone"))
{
Destroy(gameObject);
}

}
}

 Eggcollection Script (Collectable object) :

using [Link];
using [Link];
using UnityEngine;

public class eggcollection : MonoBehaviour


{
public int eggvalue = 1;
// Start is called before the first frame update
void Start()
{
}

// Update is called once per frame


void Update()
{

private void OnTriggerEnter2D(Collider2D other)


{
Destroy(gameObject);

if([Link]("Player"))
{
[Link](eggvalue);
}
}
}

 Score Script :

using [Link];
using [Link];
using UnityEngine;
using TMPro;

public class Score : MonoBehaviour


{
public static Score instance;
public TextMeshProUGUI text;
int score;
// Start is called before the first frame update
void Start()
{
if(instance == null)
{
instance = this;
}

}
// Update is called once per frame
void Update()
{

}
public void checkScore(int eggvalue)
{
score += eggvalue;
[Link] = "X" + [Link]();
}
}

Das könnte Ihnen auch gefallen