martes, 7 de febrero de 2023

videojuego para mobile phones; y tambien pc windows web gl;

πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„
 
😜😜😜😜😜😜😜😜😜😜😜😜😜😜😜😜😜😜😜😜😜😜😜😜😜😜😜😜😜😜😜😜😜😜😜
 
 
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ALKLICARRATONNIVEL1 : MonoBehaviour
{
    
        void Start () {


       
        }


    
        void Update () {

    if (Input.GetButton ("Fire1"))
            {

                        Application.LoadLevel (1);



        }
    }
}
 
 πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€
 
 
😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏

 

 

 


 

Estoy probando hacer videojuegos para poderlos jugar desde telΓ©fonos mΓ³viles, con los navegadores de internet que tienen la mayorΓ­a, este ejemplo que quiero trabajarme lo funciona en los pc con Windows y el mouse y en los telΓ©fonos con el tacto del dedo, se puede giar y se puede disparar con el dedo tocando la pantalla, tiene un script para que el cubo se mueva solo y otro para que pueda inclinar lo y asΓ­ frenarlo o darle marcha atrΓ‘s , aparte al dar toques en la pantalla se producen los disparos, derribamos unos pilares y recogemos unas capsulas para sumar puntos….apartir de hay lo que se me ocurra y lo que la memoria de mi telΓ©fono aguante,,,,en fin irΓ© haciendo y comentando...pongo los scripts en C# que utilizo y el juego esta echo con Unity…


using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class muebeladodespacio : MonoBehaviour {


// Use this for initialization

void Start () {

}




// Update is called once per frame

void Update () {


transform.position += transform.forward * 1.2f * Time.deltaTime; }


}






😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁


😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁

πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰









using System;

using UnityEngine;

using UnityStandardAssets.CrossPlatformInput;


namespace UnityStandardAssets.Utility

{

public class SimpleMouseRotator : MonoBehaviour

{

// A mouselook behaviour with constraints which operate relative to

// this gameobject's initial rotation.

// Only rotates around local X and Y.

// Works in local coordinates, so if this object is parented

// to another moving gameobject, its local constraints will

// operate correctly

// (Think: looking out the side window of a car, or a gun turret

// on a moving spaceship with a limited angular range)

// to have no constraints on an axis, set the rotationRange to 360 or greater.

public Vector2 rotationRange = new Vector3(70, 70);

public float rotationSpeed = 10;

public float dampingTime = 0.2f;

public bool autoZeroVerticalOnMobile = true;

public bool autoZeroHorizontalOnMobile = false;

public bool relative = true;

private Vector3 m_TargetAngles;

private Vector3 m_FollowAngles;

private Vector3 m_FollowVelocity;

private Quaternion m_OriginalRotation;



private void Start()

{

m_OriginalRotation = transform.localRotation;

}



private void Update()

{

// we make initial calculations from the original local rotation

transform.localRotation = m_OriginalRotation;


// read input from mouse or mobile controls

float inputH;

float inputV;

if (relative)

{

inputH = CrossPlatformInputManager.GetAxis("Mouse X");

inputV = CrossPlatformInputManager.GetAxis("Mouse Y");


// wrap values to avoid springing quickly the wrong way from positive to negative

if (m_TargetAngles.y > 180)

{

m_TargetAngles.y -= 360;

m_FollowAngles.y -= 360;

}

if (m_TargetAngles.x > 180)

{

m_TargetAngles.x -= 360;

m_FollowAngles.x -= 360;

}

if (m_TargetAngles.y < -180)

{

m_TargetAngles.y += 360;

m_FollowAngles.y += 360;

}

if (m_TargetAngles.x < -180)

{

m_TargetAngles.x += 360;

m_FollowAngles.x += 360;

}


#if MOBILE_INPUT

// on mobile, sometimes we want input mapped directly to tilt value,

// so it springs back automatically when the look input is released.

if (autoZeroHorizontalOnMobile) {

m_TargetAngles.y = Mathf.Lerp (-rotationRange.y * 0.5f, rotationRange.y * 0.5f, inputH * .5f + .5f);

} else {

m_TargetAngles.y += inputH * rotationSpeed;

}

if (autoZeroVerticalOnMobile) {

m_TargetAngles.x = Mathf.Lerp (-rotationRange.x * 0.5f, rotationRange.x * 0.5f, inputV * .5f + .5f);

} else {

m_TargetAngles.x += inputV * rotationSpeed;

}

#else

// with mouse input, we have direct control with no springback required.

m_TargetAngles.y += inputH*rotationSpeed;

m_TargetAngles.x += inputV*rotationSpeed;

#endif


// clamp values to allowed range

m_TargetAngles.y = Mathf.Clamp(m_TargetAngles.y, -rotationRange.y*0.5f, rotationRange.y*0.5f);

m_TargetAngles.x = Mathf.Clamp(m_TargetAngles.x, -rotationRange.x*0.5f, rotationRange.x*0.5f);

}

else

{

inputH = Input.mousePosition.x;

inputV = Input.mousePosition.y;


// set values to allowed range

m_TargetAngles.y = Mathf.Lerp(-rotationRange.y*0.5f, rotationRange.y*0.5f, inputH/Screen.width);

m_TargetAngles.x = Mathf.Lerp(-rotationRange.x*0.5f, rotationRange.x*0.5f, inputV/Screen.height);

}


// smoothly interpolate current values to target angles

m_FollowAngles = Vector3.SmoothDamp(m_FollowAngles, m_TargetAngles, ref m_FollowVelocity, dampingTime);


// update the actual gameobject's rotation

transform.localRotation = m_OriginalRotation*Quaternion.Euler(-m_FollowAngles.x, m_FollowAngles.y, 0);

}

}

}



πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜€πŸ˜πŸ˜πŸ˜

😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊





using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class solosumar : MonoBehaviour
{



    // Create public variables for player speed, and for the Text UI game objects
    public float speed;
    public Text countText;
    public Text winText;
   




    // Create private references to the rigidbody component on the player, and the count of pick up objects picked up so far
    private Rigidbody rb;
    private int count;/// <summary>


    /// //////////////////////////////////////////
    /// </summary>
    //private int PUNTOS;/// <summary>
    /// /////////////////////////////////////////////////
    /// </summary>

    // At the start of the game..
    void Start ()
    {












        // Assign the Rigidbody component to our private rb variable
        rb = GetComponent<Rigidbody>();

        // Set the count to zero
        count = 0;

        // Run the SetCountText function to update the UI (see below)
        SetCountText ();

        // Set the text property of our Win Text UI to an empty string, making the 'You Win' (game over message) blank
        winText.text = "";
    }




    // When this game object intersects a collider with 'is trigger' checked,
    // store a reference to that collider in a variable named 'other'..
    void OnTriggerEnter(Collider other)
    {
        // ..and if the game object we intersect has the tag 'Pick Up' assigned to it..





        //if (other.gameObject.CompareTag ("ogri2"))
        //if (other.gameObject.CompareTag ("mini"))
            if (other.gameObject.CompareTag ("suma"))

        //if (other.gameObject.CompareTag ("Terrain"))

       


        {
            // Make the other game object (the pick up) inactive, to make it disappear
            //other.gameObject.SetActive (false);///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            // Add one to the score variable 'count'
            count = count + 1;









            // Run the 'SetCountText()' function (see below)
            SetCountText ();
        }
            }

    // Create a standalone function that can update the 'countText' UI and check if the required amount to win has been achieved
    void SetCountText()
    {
        // Update the text field of our 'countText' variable
        //countText.text = "Count: " + count.ToString ();

        countText.text = "puntos: " + count.ToString ();
        // Check if our 'count' is equal to or exceeded 12
        //if (count >= 999)
        if (count >= 5)
        {


//Application.LoadLevel (1);
            // Set the text value of our 'winText'
            //winText.text = "COMPLETADO";

            //TextMeshPro = "CAMPEON GANASTES";

    

            //Destroy (gameObject, 1.2f); ////////////PROBAR TAPANDO ESTO
            //Destroy (gameObject, 0.0f);

       

        }
    }
}
    

πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›πŸ˜›

πŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒ