Tuesday, April 20, 2021

Edward Lance Lorilla

Edward Lance Lorilla


【Redux 】CRUD Rematch Library Create Read Update Delete

Posted: 19 Apr 2021 08:13 PM PDT

【GAMEMAKER】Dual View Bomber Man Game

Posted: 19 Apr 2021 08:50 AM PDT

 Information about object: obj_splash

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

//set up globals and goto game room
global.player_bombs=0;
global.enemy_bombs=0;
health=100;
global.enemy_health=100;
room_goto(room_1_player);

Information about object: obj_player_1
Sprite: spr_player_1
Solid: false
Visible: true
Depth:
-2
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Create Event:
execute code:

///setup
move_dx = 0;
move_dy = 0;
move_amt = 0;

image_index=0;
image_speed=0;

can_hurt=true;

Alarm Event for alarm 5:
execute code:

can_hurt=true;
Step Event:
execute code:

///MOVEMENT
if (move_amt > 0)
{
// moving towards destination
if (scr_move(move_dx, move_dy))
{
move_amt -= 1;
}
else move_amt = 0; // if hit a wall, stop moving
}
else
{
var spd = 4; // movement speed (grid size should divide by it w/o remainder)
move_amt = 32 div spd; // calculate number of steps for movement
move_dx = 0;
move_dy = 0;
if (keyboard_check(vk_left)) && !(position_meeting(x-18,y,obj_wall))//move if only 1 block and pos free
{
move_dx = -spd;
}
else if (keyboard_check(vk_right)&& !(position_meeting(x+18,y,obj_wall)))
{
move_dx = spd;
}
else if (keyboard_check(vk_up) && (!position_meeting(x,y-18,obj_wall)))
{
move_dy = -spd;
}
else if (keyboard_check(vk_down))&& !(position_meeting(x,y+18,obj_wall))
{
move_dy = spd;
}
else move_amt = 0; // don't move if no buttons are pressed
}
execute code:

///DROP BOMB
if (keyboard_check_pressed(ord('Z')) && global.player_bombs>0)
{
global.player_bombs--;
instance_create(x,y,obj_bomb);
scr_sound(snd_drop_bomb);
}
execute code:

///sprite control
//move_dx, move_dy
if move_dx>0 image_index=3;
if move_dx<0 image_index=1;
if move_dy>0 image_index=0;
if move_dy<0 image_index=2;
Collision Event with object obj_ammo:
execute code:

///increase no of bombs
global.player_bombs+=5;
with (other) instance_destroy();
instance_create(5,5,obj_ammo);
scr_sound(snd_ammo);
Collision Event with object obj_explosion:
execute code:

if can_hurt
{
health--;
scr_sound(snd_ouch);
can_hurt=false;
alarm[5]=room_speed;//prevent hurting for one second
}
Information about object: obj_wall
Sprite: spr_wall
Solid: true
Visible: true
Depth: 0
Persistent:
false
Parent:
Children:
Mask:

No Physics Object
Information about object: obj_hud_1
Sprite:
Solid: false
Visible: true
Depth:
-100
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Step Event:
execute code:

///test lives
if health<1 or global.enemy_health<1
{
room_goto(room_game_over);
}

Draw GUI Event:
execute code:

draw_set_halign(fa_center);
draw_text(400,750,"Player 1 - Arrow Keys Move - Z Drop Bomb");
draw_text(20,20,"Plater Health "+string(health));
draw_text(400,20,"Enemy Health "+string(global.enemy_health));
draw_set_halign(fa_left);
draw_text(20,50,"Player Bombs "+string(global.player_bombs));
draw_text(20,80,"Enemy Bombs "+string(global.enemy_bombs));
Information about object: obj_bomb
Sprite: spr_bomb
Solid: false
Visible: true
Depth:
-5
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Create Event:
execute code:

move_snap(32,32);
life=5;
alarm[0]=room_speed/4;
Alarm Event for alarm 0:
execute code:

life--;
alarm[0]=room_speed/4;
Step Event:
execute code:

///create explostion
if life==0
{
scr_sound(snd_explosion);
//create exp at position
instance_create(x,y,obj_explosion);

//create up
if !position_meeting(x,y-32,obj_wall)
{
instance_create(x,y-32,obj_explosion);
if !position_meeting(x,y-64,obj_wall)
{
instance_create(x,y-64,obj_explosion);
if !position_meeting(x,y-96,obj_wall)
{
instance_create(x,y-96,obj_explosion);
}
}
}
//create down
if !position_meeting(x,y+32,obj_wall)
{
instance_create(x,y+32,obj_explosion);
if !position_meeting(x,y+64,obj_wall)
{
instance_create(x,y+64,obj_explosion);
if !position_meeting(x,y+96,obj_wall)
{
instance_create(x,y+96,obj_explosion);
}
}
}
//create left
if !position_meeting(x-32,y,obj_wall)
{
instance_create(x-32,y,obj_explosion);
if !position_meeting(x-64,y,obj_wall)
{
instance_create(x-64,y,obj_explosion);
if !position_meeting(x-96,y,obj_wall)
{
instance_create(x-96,y,obj_explosion);
}
}
}
//create right
if !position_meeting(x+32,y,obj_wall)
{
instance_create(x+32,y,obj_explosion);
if !position_meeting(x+64,y,obj_wall)
{
instance_create(x+64,y,obj_explosion);
if !position_meeting(x+96,y,obj_wall)
{
instance_create(x+96,y,obj_explosion);
}
}
}
instance_destroy();
}


Collision Event with object obj_explosion:
execute code:

life=0;
Draw Event:
execute code:

draw_set_halign(fa_center);
draw_set_colour(c_red);
draw_self();
draw_text(x,y,life);
Information about object: obj_ammo
Sprite: spr_bomb_crate
Solid: false
Visible: true
Depth:
-30
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Create Event:
execute code:

//jump to a random free position
do
{
var _x = (random(room_width) div 32) * 32;
var _y = (random(room_height) div 32) * 32;
}
until (place_free(_x, _y));
x=_x;
y=_y;

Information about object: obj_explosion
Sprite: spr_explosion
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Step Event:
execute code:

///destroy at end
if image_index>45 instance_destroy();
Information about object: obj_game_over
Sprite:
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Create Event:
execute code:

alarm[0]=room_speed*10;
Alarm Event for alarm 0:
execute code:

game_restart();
Draw Event:
execute code:

if health<1
{
draw_text(100,100,"Enemy Wins");
}
else
{
draw_text(100,100,"Player Wins");
}

Information about object: obj_enemy
Sprite: spr_player_2
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Create Event:
execute code:

grid=mp_grid_create(0, 0, room_width div 16, room_height div 16, 16 , 16);
mp_grid_add_instances(grid, obj_wall, false);

image_speed=0;
image_index=0;
path=path_add();

mp_grid_path(grid,path,x,y,obj_ammo.x,obj_ammo.y,false);
path_start(path,3.5,path_action_stop,true);

can_hurt=true;
Alarm Event for alarm 0:
execute code:

//choose a target
target=choose("player","random");
if target=="player"
{
mp_grid_path(grid,path,x,y,obj_player_1.x,obj_player_1.y,false);
path_start(path,3.5,path_action_stop,true);
alarm[0]=room_speed*5;//prevent sticking
exit;
}
if target=="random"
{
do//find a free place
{
var _x = (random(room_width) div 32) * 32;
var _y = (random(room_height) div 32) * 32;
}
until (place_free(_x, _y));


mp_grid_path(grid,path,x,y,_x,_y,false);
path_start(path,3.5,path_action_stop,true);
alarm[0]=room_speed*8;//prevent sticking
}
Alarm Event for alarm 5:
execute code:

can_hurt=true;
Step Event:
execute code:

///image control
if hspeed>0 image_index=3;
if hspeed<0 image_index=1;
if vspeed>0 image_index=0;
if vspeed<0 image_index=2;
execute code:

///randomlly drop a bomb
rand=irandom(200);//one in 200 chance of dropping a bomb
if rand==1
{
if global.enemy_bombs>0//check player has bombs
{
global.enemy_bombs--;
instance_create(x,y,obj_bomb);
}
}
Collision Event with object obj_ammo:
execute code:

///increase no of bombs
global.enemy_bombs+=5;
with (other) instance_destroy();
instance_create(5,5,obj_ammo);
scr_sound(snd_ammo);
Collision Event with object obj_explosion:
execute code:

if can_hurt
{
global.enemy_health--;
scr_sound(snd_ouch);
can_hurt=false;
alarm[5]=room_speed;//prevent hurting for one second
}

Other Event: Game End:
execute code:

mp_grid_destroy(grid);
path_delete(path);
Other Event: End Of Path:
execute code:

///clear and update grid + drop bomb
if global.enemy_bombs>0
{
global.enemy_bombs--;
instance_create(x,y,obj_bomb);

}

//grid
mp_grid_clear_all(grid);
mp_grid_add_instances(grid, obj_wall, false);
if global.enemy_bombs<1
{
mp_grid_path(grid,path,x,y,obj_ammo.x,obj_ammo.y,false);
path_start(path,3.5,path_action_stop,true);
alarm[0]=room_speed*5;//prevent sticking
exit;
}

//choose a target
target=choose("player","random");
if target=="player"
{
mp_grid_path(grid,path,x,y,obj_player_1.x,obj_player_1.y,false);
path_start(path,3.5,path_action_stop,true);
alarm[0]=room_speed*5;//prevent sticking
exit;
}
if target=="random"
{
do//find a free place
{
var _x = (random(room_width) div 32) * 32;
var _y = (random(room_height) div 32) * 32;
}
until (place_free(_x, _y));


mp_grid_path(grid,path,x,y,_x,_y,false);
path_start(path,3.5,path_action_stop,true);
alarm[0]=room_speed*8;//prevent sticking
}


Draw Event:
execute code:

draw_self();
draw_path(path,x,y,true);

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

No Physics Object

Step Event:
execute code:

var x1 = obj_player_1.x;//get x position of player 1
var y1 = obj_player_1.y;//get y position of player 1
var x2 = obj_enemy.x;//get x position of player 2
var y2 = obj_enemy.y;//get y position of player 2
var border = 50;//set a border distance
var vscale = max(1, abs(x2 - x1) / (view_wport[0]- border * 2), abs(y2 - y1) / (view_hport[0] - border * 2)); //calculte scale needed
view_wview[0] = vscale * view_wport[0];//apply scale to view port
view_hview[0] = vscale * view_hport[0];//apply scale to view port
view_xview[0]= (x1 + x2 - view_wview[0]) / 2;//update view
view_yview[0] = (y1 + y2 - view_hview[0]) / 2;//update view


【PYTHON OPENCV】 Face tracking using dlib frontal face detector for initialization and dlib discriminative correlation filter tracker

Posted: 19 Apr 2021 08:43 AM PDT

 """

Face tracking using dlib frontal face detector for initialization and dlib discriminative correlation filter tracker """ # Import required packages:import cv2import dlib def draw_text_info(): """Draw text information""" # We set the position to be used for drawing text and the menu info: menu_pos_1 = (10, 20) menu_pos_2 = (10, 40) # Write text: cv2.putText(frame, "Use '1' to re-initialize tracking", menu_pos_1, cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255)) if tracking_face: cv2.putText(frame, "tracking the face", menu_pos_2, cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0)) else: cv2.putText(frame, "detecting a face to initialize tracking...", menu_pos_2, cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255)) # Create the video capture to read from the webcam:capture = cv2.VideoCapture("istockphoto-1131308747-640_adpp_is.mp4") # Load frontal face detector from dlib:detector = dlib.get_frontal_face_detector() # We initialize the correlation tracker.tracker = dlib.correlation_tracker() # This variable will hold if we are currently tracking the face:tracking_face = Falsewhile True: # Capture frame from webcam: ret, frame = capture.read() # We draw basic info: draw_text_info() if tracking_face is False: gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # Try to detect a face to initialize the tracker: rects = detector(gray, 0) # Check if we can start tracking (if we detected a face): if len(rects) > 0: # Start tracking: tracker.start_track(frame, rects[0]) tracking_face = True if tracking_face is True: # Update tracking and print the peak to side-lobe ratio (measures how confident the tracker is): print(tracker.update(frame)) # Get the position of the tracked object: pos = tracker.get_position() # Draw the position: cv2.rectangle(frame, (int(pos.left()), int(pos.top())), (int(pos.right()), int(pos.bottom())), (0, 255, 0), 3) # We capture the keyboard event key = 0xFF & cv2.waitKey(1) # Press '1' to re-initialize tracking (it will detect the face again): if key == ord("1"): tracking_face = False # To exit, press 'q': if key == ord('q'): break # Show the resulting image: cv2.imshow("Face tracking using dlib frontal face detector and correlation filters for tracking", frame) # Release everything:capture.release()cv2.destroyAllWindows()

【VISUAL VB.NET】Device Detection

Posted: 19 Apr 2021 08:37 AM PDT

 Imports System

Imports System.Collections.GenericImports System.ComponentModelImports System.DataImports System.DrawingImports System.LinqImports System.TextImports System.Threading.Tasks' mak System.Diagnostics ' make sure that using System.Security.Principal; is included Imports System.Security.Principal ' make sure that using System.Diagnostics; is included Imports System.Management ' add reference system.management (.NET directory) Public Class Form1 Public Enum ChassisTypes Other = 1 Unknown Desktop LowProfileDesktop PizzaBox MiniTower Tower Portable Laptop Notebook Handheld DockingStation AllInOne SubNotebook SpaceSaving LunchBox MainSystemChassis ExpansionChassis SubChassis BusExpansionChassis PeripheralChassis StorageChassis RackMountChassis SealedCasePC End Enum Public Shared Function GetCurrentChassisType() As ChassisTypes Dim systemEnclosures As New ManagementClass("Win32_SystemEnclosure") For Each obj As ManagementObject In systemEnclosures.GetInstances() For Each i As Integer In DirectCast(obj("ChassisTypes"), UInt16()) If i > 0 AndAlso i < 25 Then Return CType(i, ChassisTypes) End If Next Next Return ChassisTypes.Unknown End Function Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click MessageBox.Show(GetCurrentChassisType().ToString()) End SubEnd Class

No comments:

Post a Comment