Terence

  • Home

  • Archives

独立游戏开发 - Unity UI for Health Bar

Posted on 2020-12-26 | Edited on 2020-12-27 | In gamedev
Symbols count in article: | Reading time ≈

Unity UI for Health Bar

Create the visuals in PhotoShop

  • Rounded Rectangle

Import Assets in Unity

  • Mesh Type - Full Rect: allow sprite editing
  • create an UI image component (container for the sprite)
    • set native size
    • scale the bar from right to left: change the pivot x to 0 (Rect Transform)
    • prevent shrinking corners (squash look): slicing
      • In sprite editor
        • blue boundary: sprite extraction
        • green points: slice points
      • Image Type: Sliced
    • disable generate mip maps

Coding

独立游戏开发 - Unity UI for Collectable Items

Posted on 2020-12-26 | Edited on 2020-12-27 | In gamedev
Symbols count in article: | Reading time ≈

Unity UI for Collectable Items

Create an UI object

Comes with a canvas object. the Text object will be created as a child object to the canvas.

  • canvas

    how to display the text

    • reference resolution: choose the biggest one
    • UI Scale Mode: scale with screen size
  • text

    set up your own test config

    • font size
    • Color
    • anchor preset (for different resolution)

Coding

  1. Player class stores an integer as a counter int coinsCollected
  2. Player class stores a reference type Text to the UI text component Text coinsText

In the player object

1
2
3
4
5
6
7
8
9
10
11
// get coin status at the beginning
void Start()
{
coinsText = GameObject.Find("Coins").GetComponent<Text>();
UpdateUI();
}

public void UpdateUI()
{
coinsText.text = coinsCollected.ToString();
}

In the collectable object

1
2
3
4
5
6
7
8
9
10
11
private void OnTriggerEnter2D(Collider2D collision)
{
Debug.Log("touched!");
//If the player is touching 'me'
if (collision.gameObject.name == "Player")
{
GameObject.Find("Player").GetComponent<Player>().coinsCollected += 1;
GameObject.Find("Player").GetComponent<Player>().UpdateUI();
Destroy(gameObject);
}
}

OOD 学习笔记

Posted on 2019-04-18 | Edited on 2020-12-26 | In design
Symbols count in article: | Reading time ≈

目的: 设计一个能正常运行,并容易维护的系统

没有标准答案

  • OOA (analysis): 讨论, 分析, 获得需求
  • OOD (Design): 搭建框架
  • OOP (Programming): 写代码

坑

  • 先手

    • 先下手为强: 不要先入为主. 需要通过和面试官有效交流
    • 指鹿为马: 问清题目要求
  • 解题

    • 朝出夕改: 先给出一个可行的结果, 忌讳修修改改
  • 收手

    • 虎头蛇尾: 检查设计是否能支持所需功能

5C 解题法

  1. Clarify: 除去题中歧义, 确定答题范围
    • What
      • 取关键字(名词)
      • 考虑属性(不需要考虑与题目不相干的属性)
    • How
      • 确定规则,明确方向
      • 从简单方案开始
    • Who
  2. Core Objects: 确定题目涉及的类, 以及之间的关系
  3. Cases: 确定题目需要实现的场景和功能
  4. Classes: 通过UML图, 填充题目涉及的类
  5. Correctness: 检查设计, 是否满足关键点

Extract structured data with Ptyhon Scrapy

Posted on 2019-03-10 | Edited on 2020-12-26 | In knowledge
Symbols count in article: | Reading time ≈

scrapy commands

  • scrapy bench: run a quick benchmarking test for how Scrapy runs on your hardware (memory and disk availability)
    • setup a local HTTP server and crawls it at maximum possible speed
  • scrapy fetch “website_url”: download the html file and write its contents to stdout
  • scrapy settings: gets the config settings for scrapy shows project specific settings if this is called inside a project
  • scrapy view “website_url”: open the url in the browser the way Scrapy will “see” it.
    • dynamic content is not rendered
  • scrapy shell “website_url”: interactive shell where you quickly prototype what you want to debug without building a Spider
    • crawler
    • item
    • request
    • response
    • settings

Scrapy architecture

  • scrapy engine: controls data flow and triggers all events

data visualization with Python

Posted on 2019-03-08 | Edited on 2020-12-26 | In knowledge
Symbols count in article: | Reading time ≈

Matplotlib: data visualization library for Python

Pandas: importing, organizing and processing data

Jupyter: interactive python notebook

Anaconda: package manager for scientific libraries in Python

Pandas:

  • DataFrame
  • boolean indexing

Introduction to Anuglar NX

Posted on 2019-03-07 | Edited on 2020-12-26 | In knowledge
Symbols count in article: | Reading time ≈

Why Nx?

  • an extention of the Angular CLI
  • allow multiple Angular applications in one app (easily share code among multiple applications)
  • encourage code sharing
  • encourage to architect your app properly

Multiple repos vs monorepo

  • enterprise large apps
  • consistency
  • formalize a community approach
  • robust and proven patterns

Steps:

  1. install Angular CLI

    1
    npm install -g @angular/cli
  2. install Nx

    1
    npm install -g @nrwl/schematics
  3. create new Nx workspace

    1
    create-nx-workspace <name>
  4. Now you have a new workspace

    1. apps (where the application lives)
    2. libs (reusable chunks of functionality)
    3. tools (things to manage your workspace)

Implementing Cache for Cloud-based Application

Posted on 2019-03-07 | Edited on 2020-12-26 | In knowledge
Symbols count in article: | Reading time ≈

Why is Caching?

User reads and writes data when interact with the database.

Cache is a datastore, just like the database, but cache store data in memory so it doesn’t have to interact with the filesystem. Cache also store data in very simple data structures (e.g. key-value pair).

  • improve performance
  • increase availability

pick the right data to be cached

  • simple data
  • data that is accessed often and doesn’t change often

Invalidation policy

  • set the right poicy (e.g.retention)
  • balance between performance and consistency

pre-populate the cache (e.g. country, phone code)

What is Azure Redis Cache?

  • Cloud service designed for caching.
  • provide in-memory data storage for fast data operations
  • based on the open-source Redis cache
  • Stores data in: strings, hashes, lists and sets
  • Advanced features:
    • Geo-replication (HA)
    • Cluster (better performance)
    • data persistence (backups)

Up and running Azure Redis Cache

  1. Create and use Azrue Cache
    check this link

  2. Install NuGet package (2 options)

    StackExchange.Redis NuGet
    Microsoft.Extensions.Caching.Redis NuGet

  3. Retrieve host name, ports, and access keys

System Design 系统设计小结

Posted on 2019-03-06 | Edited on 2020-12-26 | In design
Symbols count in article: | Reading time ≈

Introduction

上个月参加了一场面试,其中问了一条system design的题目。面试前咨询了IT界资深大牛,他语重心长地建议我好好准备算法,系统设计可以胡扯一下。面试后深深觉得这种场景不能适用在我自己身上。

最近一直在思考一个问题:在下工作几年,又好好准备了2个月,为何还是有点无所适从的感觉? 题目不算难,但确实缺少面试经验。

Read more »

Dynamic Programming算法总结

Posted on 2019-03-05 | Edited on 2020-12-26 | In coding
Symbols count in article: | Reading time ≈

here is the content

Tree算法总结

Posted on 2019-03-05 | Edited on 2020-12-26 | In coding
Symbols count in article: | Reading time ≈

Content

12

Terence Chen

13 posts
4 categories
3 tags
© 2020 Terence Chen |
Powered by Hexo v3.8.0
|
Theme – NexT.Muse v7.0.1