Sunday, April 18, 2021

Edward Lance Lorilla

Edward Lance Lorilla


【VUEJS】video playback speed

Posted: 18 Apr 2021 02:53 AM PDT

【GAMEMAKER】 items that can be picked up and inventory

Posted: 17 Apr 2021 09:14 AM PDT

 Information about object: obj_inventory

Sprite:
Solid: false
Visible: true
Depth: -1000
Persistent: true
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

///Set Up
global.showInv=true; //Display the inventory?

global.maxItems=4;//total item slots

for (var i = 0; i < 12; i += 1)
{
global.inventory[i] = -1;
button[i] = instance_create(0,0,obj_invbutton)
button[i].slot = i;
}

global.mouseItem=-1;
instance_create(0,0,obj_mouseitem);


Step Event:
execute code:

///Visible switch
if keyboard_check_pressed(ord('V'))
{
global.showInv=!global.showInv;
}
Draw Event:
execute code:

///draw the inventory
if (global.showInv)
{
var x1,x2,y1,y2;
x1 = view_xview[0]+75;
x2 = x1 + view_wview[0];
y1 = view_yview[0]+30;
y2 = y1 + 64;

draw_set_color(c_black);
draw_set_alpha(0.8);
draw_sprite(spr_inv_bg,0,x1-50,y1+15);

for (var i = 0; i < global.maxItems; i += 1)
{
var ix = x1+24+(i * 40);
var iy = y2-24;

draw_sprite(spr_border,0,ix,iy)
button[i].x = ix;
button[i].y = iy;
}
draw_text(x1+100,y1+100,"V to show / hide - Click and Drag Items With Mouse##P to Pick Up##Pick Up Bag For Extra Room To Store Items");
}

Information about object: obj_mouseitem
Sprite:
Solid: false
Visible: true
Depth:
-1002
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Draw Event:
execute code:

if (global.showInv)
{
var item = global.mouseItem;
if (item != -1)
{
x = mouse_x;
y = mouse_y;
draw_sprite(spr_items,item,x,y);
}
}

Information about object: obj_invbutton
Sprite:
Solid: false
Visible: true
Depth:
-1001
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Draw Event:
execute code:

if (global.showInv)
{
var item = global.inventory[slot];
var click = mouse_check_button_pressed(mb_left);

if (abs(mouse_x - x) < 16) && (abs(mouse_y - y) < 16)
{
draw_set_colour(c_white);
draw_rectangle(x-16,y-16,x+16,y+16,0);
if (click)
{
if (item != -1)
{
scr_itemdrop_slot(slot);
}
if (global.mouseItem != -1)
{
scr_itempickup_slot(global.mouseItem,slot)
}
global.mouseItem = item;
}
}

if (item != -1)
{
draw_sprite(spr_items,item,x,y);
}
}
Information about object: obj_player
Sprite: spr_idle_down
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Create Event:
execute code:

///set up
enum state {
idle,
up,
down,
left,
right
}

dir=state.down;
is_moving=false;
image_speed=0.5;

Step Event:
execute code:

///keypress code
if (keyboard_check(vk_left))
{
dir=state.left;
is_moving=true;
}
else
if (keyboard_check(vk_right))
{
dir=state.right;
is_moving=true;
}
else
if (keyboard_check(vk_up))
{
dir=state.up;
is_moving=true;
}
else
if (keyboard_check(vk_down))
{
dir=state.down;
is_moving=true;
}
else
{
dir=dir;
is_moving=false;
}

execute code:

///movement
if is_moving
{
switch (dir)
{
case state.up:
y -= 4;
break;

case state.down:
y += 4;
break;

case state.left:
x -= 4;
break;

case state.right:
x += 4;
break;
}
}



execute code:

///animation
if is_moving
{
switch (dir)
{
case state.up:
sprite_index=spr_walk_up;
break;

case state.down:
sprite_index=spr_walk_down;
break;

case state.left:
sprite_index=spr_walk_left;
break;

case state.right:
sprite_index=spr_walk_right;
break;
}
}
if !is_moving
{
switch (dir)
{
case state.up:
sprite_index=spr_idle_up;
break;

case state.down:
sprite_index=spr_idle_down;
break;

case state.left:
sprite_index=spr_idle_left;
break;

case state.right:
sprite_index=spr_idle_right;
break;
}
}

Information about object: obj_pickup
Sprite: spr_pickup
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Create Event:
execute code:

///set up
my_id=irandom_range(1,4);
image_speed=0;
image_index=my_id;

Collision Event with object obj_player:
execute code:

///Detect Keypress & Check For Empty Slot
if keyboard_check_pressed(ord('P')) && scr_itempickup(my_id)//if slot available, add to slot
{
instance_destroy();//then destroy instance]
}

Information about object: obj_bag
Sprite: spr_bag
Solid: false
Visible: true
Depth: 0
Persistent:
false
Parent:
Children:
Mask:

No Physics Object

Collision Event with object obj_player:
execute code:

///Detect Keypress
if keyboard_check_pressed(ord('P'))
{
global.maxItems+=4;// add four inventory slots
instance_destroy();
}



【PYTHON OPENCV】dlib library to calculate the 128D descriptor to be used for face

Posted: 17 Apr 2021 09:05 AM PDT

 """

This script makes used of dlib library to calculate the 128-dimensional (128D) descriptor to be used for face recognition. Face recognition model can be downloaded from: https://github.com/davisking/dlib-models/blob/master/dlib_face_recognition_resnet_model_v1.dat.bz2 """ # Import required packages:import cv2import dlibimport numpy as np # Load shape predictor, face enconder and face detector using dlib library:pose_predictor_5_point = dlib.shape_predictor("shape_predictor_5_face_landmarks.dat")face_encoder = dlib.face_recognition_model_v1("dlib_face_recognition_resnet_model_v1.dat")detector = dlib.get_frontal_face_detector() def face_encodings(face_image, number_of_times_to_upsample=1, num_jitters=1): """Returns the 128D descriptor for each face in the image""" # Detect faces: face_locations = detector(face_image, number_of_times_to_upsample) # Detected landmarks: raw_landmarks = [pose_predictor_5_point(face_image, face_location) for face_location in face_locations] # Calculate the face encoding for every detected face using the detected landmarks for each one: return [np.array(face_encoder.compute_face_descriptor(face_image, raw_landmark_set, num_jitters)) for raw_landmark_set in raw_landmarks] # Load image:image = cv2.imread("jared_1.jpg") # Convert image from BGR (OpenCV format) to RGB (dlib format):rgb = image[:, :, ::-1] # Calculate the encodings for every face of the image:encodings = face_encodings(rgb) # Show the first encoding:print(encodings[0])

【VISUAL VB.NET】Download file via HTTP

Posted: 17 Apr 2021 08:58 AM PDT

 Imports System

Imports System.Collections.GenericImports System.ComponentModelImports System.DataImports System.DrawingImports System.LinqImports System.TextImports System.Threading.TasksImports System.Windows.Forms' make sure that using System.Diagnostics; is included Imports System.Diagnostics' make sure that using System.Security.Principal; is included Imports System.Security.Principal ' make sure that using System.Net; is included Imports System.Net Public Class Form1Public Sub New() MyBase.New InitializeComponent End Sub Private webClient As New WebClient() Private Sub webClient_DownloadProgressChanged(sender As Object, e As DownloadProgressChangedEventArgs) Dim bytesIn As Double = Double.Parse(e.BytesReceived.ToString()) Dim totalBytes As Double = Double.Parse(e.TotalBytesToReceive.ToString()) Dim percentage As Double = bytesIn / totalBytes * 100 progressBar1.Value = Integer.Parse(Math.Truncate(percentage).ToString()) End Sub Private Sub webclient_DownloadFileCompleted(sender As Object, e As AsyncCompletedEventArgs) MessageBox.Show("Saved as C:\MYRAR.EXE", "Httpdownload") End Sub#Region "basic function for app" Private Sub lblLink_Click_1(sender As Object, e As EventArgs) Handles lblLink.Click Process.Start("www.vclexamples.com") End Sub Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean If (keyData = Keys.Escape) Then Me.Close() Return True End If Return MyBase.ProcessCmdKey(msg, keyData) End Function#End Region Private Sub button1_Click(sender As Object, e As EventArgs) Handles button1.Click AddHandler WebClient.DownloadProgressChanged, New DownloadProgressChangedEventHandler(AddressOf webClient_DownloadProgressChanged) AddHandler WebClient.DownloadFileCompleted, New AsyncCompletedEventHandler(AddressOf webclient_DownloadFileCompleted) ' start download WebClient.DownloadFileAsync(New Uri(textBox1.Text), "C:\\MYRAR.EXE") End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load End SubEnd Class

No comments:

Post a Comment