Skip to content

Instantly share code, notes, and snippets.

View xSystemIOx's full-sized avatar

Lt Pui Pui xSystemIOx

View GitHub Profile
@xSystemIOx
xSystemIOx / Unity C# Loading Screen
Created March 6, 2019 19:59
Unity C# Loading screen
public GameObject loadingScreen;
public Slider slider;
public Text progressText;
public void LoadScene(int sceneIndex){
loadingScreen.SetActive (true);
StartCoroutine (LoadAsync (sceneIndex));
}
public GameObject[] locations;
public GameObject[] tiles;
List<int> Num = new List<int>();
int setTo;
int index;
// Use this for initialization
void Start () {
Shot1.Top -= ShotSpeed
If Shot1.Top + Shot1.Height < Me.ClientRectangle.Top Then
Shot1.Visible = False
End If
@xSystemIOx
xSystemIOx / Character Movement VB.NET
Created May 9, 2018 15:12
Character Movement for VB application form
Private Sub MoveShooter()
If Sright = True And Player.Left + Player.Width < Me.ClientRectangle.Width Then
Player.Left += PlayerSpeed
End If
If Sleft = True And Player.Left > Me.ClientRectangle.Left Then
Player.Left -= PlayerSpeed
End If
End Sub
@xSystemIOx
xSystemIOx / SQL for registering users with password checks
Last active May 9, 2018 15:08
Registers a user in the database with password checker
Public Class User_Register
Private Sub Register_Click(sender As Object, e As EventArgs) Handles Register.Click
Dim connection As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Path")
Dim command As New OleDbCommand("INSERT INTO [Log_in_Info]([Username], [Password]) VALUES(@Username, @Password)", connection) 'SQL query to input values in the database table
Dim usernameparam As New OleDbParameter("@Username", UsernameTXT.Text) 'username parameter
Dim passwordparam As New OleDbParameter("@Password", PasswordTXT.Text) 'password parameter
Dim check As Boolean 'delared variable
Private Sub LoadHighScore()
Dim connection As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Path")
Dim command As New OleDbCommand("SELECT [HighScore] From [Log_in_Info] WHERE [Username] = @Username", connection) 'SQL Statement to update record in database
Dim usernameparam As New OleDbParameter("@Username", Loginpage.usernametxtbox.Text) 'username parameter
Dim Score As New OleDbParameter("@HighScore", playerhighscore) 'password parameter
command.Parameters.Add(usernameparam) 'command parameter
@xSystemIOx
xSystemIOx / Spawn object between places 2D C#
Created May 9, 2018 14:41
Spawns objected between two horizontal points
if (startSpawn == true) {
if (Time.time > nextSpawn) {
nextSpawn = Time.time + spawnRate;
randX = Random.Range (-12f, 1f);
randomeObject = Random.Range (0, 8);
Vector3 spawnPoint = new Vector3 (randX, transform.position.y);
Instantiate (Objects [randomeObject], spawnPoint, Quaternion.identity);
}
}
@xSystemIOx
xSystemIOx / Player lunge
Created May 9, 2018 14:34
Lunges the player to simulate jumping from
player.transform.position = new Vector3 (LaunchPoint.position.x, LaunchPoint.position.y, 10);
Player.velocity = new Vector2 (Player.velocity.y, jumpForce);
@xSystemIOx
xSystemIOx / Fire Projectile 2D C#
Last active May 9, 2018 16:02
Fires a projectile in 2D
void Update () {
if (contact == true) {
if (Input.GetButtonDown ("Fire1")) {
Vector3 layer = new Vector3 (launchPoint.transform.position.x , launchPoint.transform.position.y , 10f);
GameObject go = (GameObject)Instantiate (shot,layer, Quaternion.identity);
go.GetComponent <Rigidbody2D> ().velocity = new Vector2 (velocity.x * (transform.position.x + 6), velocity.y);
Instantiate (recoilParticle, launchPoint.transform.position, Quaternion.identity);
SD.Play ();
shake = true;
}
@xSystemIOx
xSystemIOx / Projectile Shooter C#
Created May 9, 2018 14:26
Instantiates and launches the projectile forward
public class ProjectileShooter : MonoBehaviour {
public float speed = 200f;
public GameObject prefab;
public void Shoot()
{
GameObject projectile = Instantiate (prefab,transform.position,Quaternion.identity ) as GameObject;
projectile.transform.eulerAngles = transform.eulerAngles;
Rigidbody rb = projectile.GetComponent<Rigidbody>();
rb.velocity = transform.forward * speed;