fabiochiu/medium-articles huggingface dataset:
Practice, Practice, Practice
By: Troy Lyndon
Tags: Unity Game Development, C Sharp Programming, Gamedevhq

With three remaining tasks to complete the 2D Game Development course by GameDevHQ, I’m definitely finding myself challenged, but fortunately, there are many resources available online.

More than half the games in the world are made using Unity, so not surprisingly, this has resulted in a thriving developer community that shares information and helps you can find online. This includes thousands of Unity tutorials created by independent developers who just want to show how to use a particular function.

In most cases, this community and its resources can be used to learn how to use so much of what Unity has to offer, but once in a while, I’ve run into information that isn’t as well explained as Jonathan’s tutorials. And this is where our team leads can be of extra help.

Today, during our 2pm conference call and screen share session, my team lead Dan is going to demonstrate how to best use BoxCast, a Unity method that will help me program each enemy’s ability to see incoming lasers. I’ve already written the code to have them move up and to the left or right, depending upon which side the laser is coming at them from; just a few lines are needed.

I can see that the more work that I do extending the feature set of the Space Shooter Game, the more “PRACTICE” I’m getting into using C# in Unity. I’m definitely learning and able to write more code each day based upon this process of trial and error, through more and more practice.

Thank you to Jonathan and the Economic Development Alliance of Hawaii for making this opportunity to learn Unity possible.
Day 12: C Not So Sharp
By: Brittany Lumanlan Martin
Tags: Game Development, Gaming, Gamedevhq, Unity, C Sharp Programming

I wanted to showcase a few of the changes I made today with my free background from the Unity Assets Store and music via freemusicarchive.com

Coming out of the slump I was in yesterday was an arduous process. As you can see in the video above, my shield visualizer will now cycle through different colors. The catch is that the shield only absorbs one hit instead of the intended three, and the player can die while the shield is still active. I thought I had sorted out this buggy bit of code, but the issue persists. I plan on going back and making adjustments, but for now have decided to move forward as to not dwell on this section for too long.

The next task I completed was creating an ammo limit and counter, located in the lower lefthand corner of the game. Although I did not struggle as much with this section as I did the last, it did take me a large portion of the work day to configure.

I began this section by creating the “MAX AMMO” and “CURRENT AMMO” texts, then attached them to the UI Manager script. From there, I set the max ammo amount to 15 for the player. As for enabling the current ammo text to update each time a laser was fired, that was an entirely different animal altogether. I could see the ammo count decrease in a serialized field attached to the player, but it wouldn’t update on the front end. Finally, after many tries, I wrote a proper script to trigger the current ammo text to accurately update with each fired laser. Once the count reaches zero, the laser is disabled.

This tricky bit of script took ages to write.

Tomorrow, I will create a collectible powerup that will refill the player’s ammo count. This feature does not have a sprite, so I will have to create an animation for it — which is exciting! I am loving the process of sprite customization, and in the video above you’ll notice I’ve made adjustments to my background and music. My main focus in Phase I is of course framework, but I very much enjoy making quick personalizations to the game.
Camera Shake
By: Kristin Treder
Tags: Unity Game Development, Learning To Code, Cameras, Unity, C Sharp Programming

Today I implemented a camera shake effect whenever the player incurs damage. After perusing a number of tutorials on YouTube, I settled on one that created a basic animation by slightly moving the camera. Here were the main steps of what I did:

Create an idle animation (where the camera is stationary) which constantly runs until the camera shake animation method is called.

Create a basic animation with the main camera by using the main camera starting position, shifting it slightly to the left, back to center, slightly to the right, and then back to center.

Create transitions between these two animations (in the Animator) and add an OnTrigger event that can be called to switch from idle to camera shake states.

Create a new GameObject (CameraManager) and attach a new C# script to house the camera shake method.

Make a handle for CameraManager in Player script and call the _cameraShake( ) method in the damage method of Player.

Camera shake every time player incurs damage.

This worked out pretty well but I think the shake I made may be just a little too dramatic. The drawback of using the animation strategy is that in order to adjust the amount of shake, a whole new animation needs to be made. I did see (in some other tutorials) that the camera shake effect, its magnitude, as well as duration, were all able to be modified in code when the effect was created in code. So the current camera shake stays for now while I evaluate if it is, in deed, too much.

Next I’ve decided to tackle the Secondary Fire Powerup and make a new projectile. I’ll also be making a new Powerup for this weapon and I’ll have to figure out how to make it spawn rarely versus the current spawning which has been random so far.
Day 11: Stubborn Determination
By: Brittany Lumanlan Martin
Tags: Game Development, Gamedevhq, Unity, Challenge, C Sharp Programming

This was an extremely tough day for me. I’m on Phase I of the 2D Game Development course, working on a task requiring the player’s shield (once collected) to absorb damage from three enemy hits before powering down on a fourth hit. The key here is that this effect must be shown visually, which can be done a number of ways, but I have chosen to demonstrate this through changing the color of the shield sprite. The goal: one hit and the shield turns green, a second and it turns magenta, a third turns it red, and a fourth hit destroys the shield.

After many hours of trying to arrange this both in Unity and in script, I managed to get the player itself to cycle through these colors, but not the shield. When the work day came to a close, I decided to take a break before pushing forward. I couldn’t relax and kept thinking about how to solve the issue at hand, and so I hopped back onto my laptop and tried again. And again. And again.

Finally, at the end of the night, seemingly by an absolute miracle, my plan worked out. Well, sort of — the powerup shield now cycles through three colors before disappearing, but the shield function itself isn’t working and the player absorbs the damage and dies. Despite this, it’s a much smaller problem to tackle and I feel confident in my ability to fix it next. Learning to code hasn’t been the easiest journey, but it’s important to revel in the small victories everyday.
C#, Unity and Globals
By: Troy Lyndon
Tags: Unity Game Development, C Sharp Programming, Gamedevhq

One advantage that comes with age is wisdom, that is if we choose to learn from our mistakes. Relevant to this concept, this 2D Game Development course has been a challenge for me because preconceived ideas from experience have been getting in my way. This is not a problem, so long as I remain patient with the speed, or lack thereof, of my progress.

These past two days have been very productive because I’ve been able to refine a better way to create and use 1) global variables and subroutines, and 2) developed an improved way to manage and filter Debug.Log.

Globals — in my earlier blog, I used a static class. But I began to see that I could not reference any monobehaviour class. And this was a big problem. I found the following solution worked by using static public variables and routines within a typical, Unity-centric monobehavior class as follows:

Step 1 — create a basic script as follows:

Be sure to read this script to understand my comments. You may not need the setMode routine, but it is an example routine.

Step 2 — in the opening scene, be sure to create an Empty object and attach this V.cs script to it. You will notice the “Awake” method uses DontDestroyOnLoad(this) reference so that this script remains accessible no matter what scene you are in.

2. Improving Debug.Log — use the following code to use an improved Debug.Log feature. As you read the code carefully, and the comments therein, you’ll see why this routine can be indispensable.

This week, I’m hopeful to finish the 2D Game Development Course including Phase Two! Thank you again to everyone who has made this project available.
Encryption and Decryption in C#
By: Sankhadip Samanta
Tags: Decryption, Aspnetcore, C Sharp Programming, Encryption, Programming

Credit to Cloudsoft Zone

In this article, I am going to discuss various Encryption and Decryption technique.

There are basically two types of algorithms that are used for Encryption and Decryption.

Symmetric Encryption

In this algorithm, a single key is used for both Encryption and Decryption. It’s comparatively faster than its equivalent Asymmetric Encryption.

Symmetric Encryption is a kind of computerized algorithm that uses a specific key to secure an electronic message. Its conversion technique follows certain mathematical steps along with a private key, which makes it difficult for a hacker to decrypt. It’s a two-way algorithm where we can decrypt the cipher text using the same private key.

In this type of encryption, both sender and receiver need to know the secret key which may have some security problems.

Example of Symmetric Encryption

Blowfish

AES (Advanced Encryption Standard)

RC4 (Rivest Cipher 4)

DES (Data Encryption Standard)

RC5 (Rivest Cipher 5)

RC6 (Rivest Cipher 6)

Asymmetric Encryption

We have studied that Symmetric Encryption has a security concern. Here comes Asymmetric Encryption which will help to solve security concern as two different key is used for both Encryption and Decryption. One is the Public key which is used for Encryption and another is the Private key which is used for Decryption.

Asymmetric encryption is slower than symmetric encryption due to the longer key lengths and the complexity of the encryption algorithms used. In order to maintain security, asymmetric encryption must make it too difficult for a hacker to crack the public key and discover the private key.

Example of Asymmetric Encryption

RSA (Ron R ivest, Adi S hamir, and Leonard A dleman)

ivest, Adi hamir, and Leonard dleman) DSA (Digital Signature Algorithm)

Now, Let’s dive into coding how both these Encryption techniques will work.

DES Data Encryption Standard

DES has been an old traditional way for encryption and decryption. It’s also vulnerable to hackers, therefore its demand has been in decline. Also, the key used to encrypt is very short in length.

It’s not best where data flows over the network.

Thanks to CSharpcorner.com

AES Advanced Encryption Standard

The enhancement was a must need as DES has not been best due to its vulnerability and its updated version 3DES is relatively slow.

The Advanced Encryption Standard, or AES, is also called the Rijndael cipher.

AES-128 uses a 128-bit key length to encrypt and decrypt a block of messages, while AES-192 uses a 192-bit key length and AES-256 a 256-bit key length to encrypt and decrypt messages. Each cipher encrypts and decrypts data in blocks of 128 bits using cryptographic keys of 128, 192, and 256 bits, respectively.

Symmetric, also known as secret keys, ciphers use the same key for encrypting and decrypting, so the sender and the receiver must both know and use the same secret key.

That’s all I have for today. I will be looking forward to putting a more detailed explanation and implementation.
Five Simple Ways to Produce High-Quality Code
By: Dler Ari
Tags: Programming Tips, Clean Code, Software Development, Programming, C Sharp Programming

Have you ever worked on a project and cannot figure out the purpose of the code. You navigate between files, run the code a couple of times, read the code-comments, and also the documentation just to get some insight into what the code does. You are not alone, these are symptoms of poor code quality. The purpose of writing clean code does not necessarily mean one can easily understand code within a few minutes, but can surely reduce some unnecessary overhead, for you, and for others.

The aim of this article is to share with you some simple concepts to increase your programming skills, these examples are written in C#, but can also be applied to other programming languages. This article is inspired by Clean Code for .NET Core — a GitHub repository you can find here with lots of great tips.

As software developers, it is our responsibility to produce code that is readable, maintainable, and extendable, so here are a few ways you can improve your programming skills.
Lightweight Concurrency in C# — Part 2
By: Farid Jafarov
Tags: Tasks, Wait, C Sharp Programming

Waiting for a task to complete

Obviously, after finished tasks it returns some value or void based on the developed design. Here, there is an important point that I want to mention, if Task returns value, waiting happens implicitly. Otherwise, we need to wait explicitly. That’s one of the base differences between Task and Task<TResult>.

We can simulate this with below code sample:

Task A = Task.Factory.StartNew(() =>

{

Thread.Sleep(3000);

Console.WriteLine("Task A executed for 3 seconds");

});



Console.WriteLine($"Execution of task A completed!");

If we run this code, we will see first output outside of task immediately and after a few seconds (3 in our case) we will see the task’s result. So, waiting of task should happen explicitly with Wait function as below:

Task A = Task.Factory.StartNew(() =>

{

Thread.Sleep(3000);

Console.WriteLine("Task A executed for 3 seconds");

});

A.Wait();//waiting for task to complete

Console.WriteLine($"Execution of task A completed!");

But at above example, we clearly can see that main thread is suppressed to wait for task A to complete its job.

But in case Task return some value, as below:

Task<int> A = Task.Factory.StartNew<int>(() =>

{

Thread.Sleep(3000);

Console.WriteLine("Task A executed for 3 seconds");

return 5+6;

});



Console.WriteLine($"Execution of task A completed!

Result:{A.Result}");

Via A.Result property main thread actually waits for Task A to complete its job, however, it happens implicitly.

Wait method can take a few parameters including:

a. Wait(Int32) Duration (Waits for the task to complete its execution within a specified number of milliseconds);

b. Wait(CancellationToken ) (waits for the cancellable Task to complete);

c. Wait(TimeSpan) (Waits for the task to complete execution within a specified time interval).
คืนชีวิตให้ Technical Document บน ASP.NET Core 3.1 ด้วย XML Comments + SwashBuckle + Redoc
By: Sirirat Rungpetcharat
Tags: Aspnetcore, Swagger, Redoc, Living Documentation, C Sharp Programming

CTO @ Builk One Group, Cat lover and developer who believe that nothing is impossible
LINQ in c# : concise guide. LINQ (Language Integrated Query) is a…
By: Shubham Nikam
Tags: Net Core, Lambda, Linq, Dotnet Core, C Sharp Programming

LINQ (Language Integrated Query) is a uniform query syntax in C# to retrieve data from different sources and formats. LINQ generalizes the query interface by eliminating most of the hurdles to make raw data query/operation ready and as a result, LINQ returns an object for easy accessibility.

Required Namespace

using System;

using System.Linq;

using System.Collections.Generic;//for method LINQ

Three Parts of a Query Operation

At the time of actual query execution of dataQuery executes & creates IEnumerable<T> as result set which replaces dataQuery in foreach.

// 1. Obtain the data source

int[] dataList = new int[7] { 0, 1, 2, 3, 4, 5, 6 }; // 2. Query creation

var dataQuery = from num in dataList

where (num % 2) == 0

select num; // 3. Query execution

foreach (int num in dataQuery)

{

Console.Write("{0,1} ", num);

}

Two ways to write LINQ
How to use CSS isolation in Blazor .net 5
By: Taurius Litvinavicius
Tags: Css Isolation, Blazor, C Sharp Programming

CSS isolation allows you to have one CSS file for one .razor file and here is how to use it…

The idea is to have CSS classes that can only be accessed in a particular .razor file (Component or page). To achieve this you simply need to get the naming of files right. With that, both .razor and associated CSS file must be in the same folder.

For example:

Component1.razor

Component1.razor.css

You can see that the name has to match, but also the first extension must exist as well. You cannot do Component1.css, as it will not work.
Game Dev in Progress… Day 33
By: Cristian Aspacio
Tags: Intern, Game Development, Project Management, Unity, C Sharp Programming

Photo by Marten Bjork on Unsplash

Aloha Friday!!! Today has been a chill day for me. I finished the feature I was working on and managed to push it up to our main Repo where we are all storing our Scripts. I was afraid I was going to break something but it seemed alright. Dylan, my teammate that is managing the repo, did not fair as well as me. When he tried to pull from the main repo, he forgot to push his changes first and that made it so my changes overwritten and I had to push again. Luckily it wasn’t that bad and we managed to get it right.

Other then that, I managed to browse through freesound.org to find some cool sound effects for the fireball and lasers. I also browse a bit around the internet and managed to grab a couple of background music that we might be able to use. I attached an audio component on some of the assets to test them out and they seem alright. Just need to talk to Ryan whose also handling the audio, to see how were going to implement the sound system. Here’s some gameplay with audio:

I might adjust the audio a bit more to find a good volume so I don’t accidently bust people’s eardrums. The last thing I did today was to incorporate the changes in the main repo into my dev branch on my local repo. I worked out well and my dev branch was up to date. With this, I now have Dylan’s Final Boss added and working in my version of the game. Here is his Final Boss working on my computer:

As you can see, it moves but isn’t doing any of it’s attacks. The reason why is because I don’t have the assets that Dylan has in order to make them work, I only have to scripts for their behavior not the object themselves. I think that’s going to be one of the main difficulties in this project is sharing and getting the assets working for everyone in the team. Other then that, the final boss looks really well done. You can check it out a fully working one on Dylan’s Blog.

Overall, I’m proud of the progress we are making during the first week of the project. A lot of it was setting up and getting everybody up to speed with the development process. Next week, I’m going to pick up my pace and get my features done a bit quicker and up to the minimum viable product standards. Anyways, have a wonderful weekend!

_

Cristian Aspacio
Methods in C#
By: Obomighie Sophie
Tags: Newbie, Methods, Junior Developer, C Sharp Programming

This article explains Methods in C# using various analogies. Why analogies? I learn faster that way and I’m sure it’s the same for a lot of other folks.

What is a method?

A method is a code block that contains a series of statements [1] . Statements as well, are executed by a program.

You can liken a method to a box of matches which contains multiple match sticks and statements are executed just like you would ignite a match stick with the striking surface on the match box.

Photo by Gary Ellis on Unsplash

The program ,which executes the method, calls the method first of all and specifies all the required method arguments.

I apply my mind to the process of lightening the match box and lift the match box from the surface and determines if it will work and how much effort/force needs to be applied by the human (me) and the stick.

In C#, every executed instruction is performed in the context of a method. The lightning of the match stick happens in relation to the match box

The Main method is the entry point for every C# application and it’s called by the common language runtime (CLR) when the program is started.

main method like a type of match box.
Day 10: The Enemy Strikes Back
By: Brittany Lumanlan Martin
Tags: Internships, Gamedev, Gamedevhq, Aloha Connects Innovation, C Sharp Programming

I’m 98% completed with the 2D Game Development course! Today I started off with the “Deployment (Build Your Game)” section, a three-part walkthrough where I learned how to prepare my game for Mac, PC, Linux, and Web GL.

Testing my game out in a fullscreen window felt amazing. All the work that goes into coding movement, actions, audio— to see it all come together was incredibly rewarding. This time two weeks ago, on the day of my onboarding, I was quite intimidated by the thought of learning C# and how to navigate Unity. In fact, I wasn’t sure if I would make it this far into the course. There’s a long road ahead and I still have so much more to learn to become a fully realized software developer, but I’m extremely proud of myself for persevering.

Next, I made it to the “Galaxy Shooter Extras” section, with tips and challenges to refine the look and feel of the space shooter. The toughest challenge for me was programming the enemy ships to return fire at the player. At first, the enemy lasers would fire and freeze in the middle of the screen. When I resolved that bug, I somehow scrambled the code for the player’s laser along the way and it wouldn’t fire at all. When I can’t seem to straighten out a bug on my own, utilizing the Unity Scripting API and searching their forums is always a huge help — which is exactly what I did here. It turns out that a tricky line of code I had problems with a few blogs back reared its head again. Destroy(this.gameObject); was the culprit, this time destroying the lasers for the player every time I hit the space key. I’ve learned that it’s so important to pay attention to details such as these, because one line of misplaced code within the wrong curly brackets can get you stuck in a deep space catastrophe for an hour or two.

I’ve now moved on to Phase I of the 2D course, a true test of the skills I’ve learned. This section consists of a checklist of tasks to complete without the assistance of educational videos from previous sections. My first task has been completed and I’ll be researching the others over the weekend!
Day 9: If an Asteroid Explodes in Space and No One is Around to Hear It, Does It Make a Sound?
By: Brittany Lumanlan Martin
Tags: Coding, Game Audio, Gamedevhq, Unity, C Sharp Programming

It sure does in Galaxy Shooter, because the asteroid is attached to a script coded to play an audio clip upon being impacted by a laser. As it should.

The asteroid in question.

After spending the morning reviewing previous modules and sorting out bugs in my code, I cleared out my console of warning and error messages. With all sprites animated, texts updating, and spaceships moving at intended speeds, I moved into the “Game Audio” section.

Just as in “Post Processing”, adding audio brought the game to a new level. When I think of iconic game soundtracks from my childhood, Pokemon Red/Blue and Legend of Zelda: Ocarina of Time come to mind. Two of my favorites from those games are the haunting ‘Lavender Town Theme’ and suspiciously upbeat ‘Lost Woods’ (cheery music coupled with a Club Moblin charging you is jarring when you’re six years old). I enjoyed this section and went through it with confidence until the very end in the “Powerup Sound Challenge”. It was a little tricky to figure out how to initiate the powerup sound as the player collects them, but ultimately it comes down to choosing the correct method.

This is the method used to communicate with the audio source to play the “powerup” clip as the player collects a powerup.

At this point I’ve got a fully functional game on my hands and am on the “Deployment (Build Your Game)” section, getting ready to set it up for Web GL compatibility. It’s a very exciting time and I’ll be sure to post a clip of gameplay after completing the next section, “Galaxy Shooter Extras”.
Lightweight Concurrency in C# — Part 1
By: Farid Jafarov
Tags: Tasks, Threads, C Sharp Programming

What a TASK

First of all, to use Task class in our program we need to import System.Threading.Tasks library.

Image 1. Running 2 different return valued tasks

There are multiple ways of creating and running tasks. In the above example, Task.Run was used to start task immediately after its creation. All tasks have an unique ID, which is useful to track tasks in system and user level.

dummyTaskA.Id //Gets an ID for this instance

Tasks can return either void or approximately any type of objects after completed its job. “dummyTaskA” returns no value (or void) after completing its job, but for the tasks which return value it is mentioned in “<>” after Task class. For example, Task<double> will return double.

Task<double> dummyTaskC = new Task<double>(func);



double func()//Dummy method which returns double

{

return 5.5 * 11.6;

}



dummyTaskC.Start();//start(run) task

Either lambda expression (anonymous function) or custom functions can be send to task. Both of the examples in Image 1, use lambda expression as a function to execute in task. Also in above code snippets, custom method called “func” was used in task. This type of task creations are also popular, because we can create task in any part of code and start in different place when it is needed. It is also useful for Task pooling purposes.
Healthy as a horse.
By: Kristin Treder
Tags: Unity Game Development, 2d Game Development, Learning To Code, Unity, C Sharp Programming

This morning I started implementing my health power-up after conducting the preliminary research last night. Here’s what I did:

Imported the .png file of my choice into my assets folder and converted it into a 2D sprite (see last post for pixilated heart png file)

Added all the necessary fixin’s so that it interacts as desired (2D collider, rigidbody 2D, On Trigger, no gravity, etc.)

Added health to my power-up array in order to use existing power-up functionality of randomly spawning at top of screen and then moving downward

Added a function to my player that, upon collection, increases lives until max of 3 and updates UI manager to display corresponding number of lives

Added another function to player that updates player animations which correspond to current number of lives

Next up on the list was to create an ammo collectable power-up that replenishes the ammo count (even though I haven’t yet set up the ammo count functionality yet). I figured this would be an easy one to knock out seeing as it will be just like the first parts of what I just did. Here was my new to do list:

Who knew bullets could be cute?

Find ammo png (I stuck with the theme and chose a pixilated bullet with a face, see above)

Import to assets folder and convert ammo .png to sprite

Expand powerup array by 1 ( to [0,5] )

Add ammo into power up switch

Here are both the health powerup and ammo powerup in action:

Tomorrow I’ll implement the ammo count functionality as well as a display to indicate ammo level. Here’s my preliminary to do list:
Should i learn C sharp in 2020?
By: Arunoday Singh
Tags: Website, C Sharp Programming, Cryptocurrency, Web Development, JavaScript

Hello, my fellow readers!! Technology has undergone many changes throughout the years. For those who want to become developers ask this question quite often “Which language is worth learning it”? Let’s dive into together and know more about C#.

What is C#?

C#( pronounced as C sharp) is a general, purpose, modern,object-orientated language developed by Microsoft that runs on .NET framework. So, now you might be wondering what is .NET?

.NET is a free open source developer platform used for building many types of applications. With .NET, you can use multiple languages, editors, and libraries to build for web, mobile, desktop, games, and IoT.

Features of C#

· C# is a simple and modern language as it is based on the current trend.

· C# code doesn’t require a header file.

· C# supports all three OOP features.

· Syntax of C# is quite familiar with C, C++, or Java.

· C# has a rich library with many inbuilt functions for easy and fast development.

· C# supports all IDE’s and editors.

Why C# is among the most popular languages?

In-Demand Skill

C# is mainly used for game development using the Unity game engine, which is quite popular among the people. It is also the 3rd largest community on StackOverflow (which was built using C#) with more than 1.1 million topics.

.NET framework

The . NET framework provides increased application security as internet software is developed by ASP. When the turn comes of quality .NET framework presents additional versatile and flexible mobile applications.

The .NET framework makes arrangements quite simple for the development of the post.

Future marketability

Does C# have a future? Well, that’s a tricky question.

Yes, it is highly marketable and in demand as it can be used to create almost any type of desktop application and mobile application because of its simple syntax and high performance.

Conclusion:

To sum it up, C# remains the well-rooted language. It will give you great job stability and salaries that are on the higher end of the market.

C# has powerful tools with larger communities.

In whichever language you choose to develop in “First, solve the problem. Then, write the code.” — John Johnson.

Happy Coding ! Sharing is Caring (share with your friends and family.)
Day 8: Set Phasers to DESTROY
By: Brittany Lumanlan Martin
Tags: Vfx, Game Development, Gamedevhq, Unity, C Sharp Programming

I do love a good animated explosion, and luckily, the bulk of my day was spent learning in the section “Effects (VFX)”. Nearly a decade ago now, I once majored in graphic design. Although I didn’t complete my degree, I’ve always loved art — especially visual arts — and was extremely excited to get to this section of the course. I’m clearly quite the novice here when it comes to game animation, but just to be able to toggle the hue, saturation, and intensity of the Filebase sprites brought me back to my roots. I’d love to learn more about post-production editing in the future.

To start off the day, I finally got through fixing my score text to update each time the player destroys an enemy. Ultimately, I couldn’t find the issue and decided to go back and redo that section of “User Interface (UI)”, which ended up being far less difficult than trying to find one line of buggy code.

After getting back on track, I moved into the “Effects” section where I added animations for enemy explosions and coded the behavior for them. Another added feature, to start off the game, is an astroid upon which being destroyed triggers the enemies and powerups to begin spawning— referred to as a “spawn wave”. You also may note that it subtly rotates in place.

It’s amazing to see how far I’ve come in a little over a week! Also, let’s talk about this background music. It really ties everything together. *chef’s kiss*

Lastly, to round off this section, a thruster animation was added to the tail of the player’s ship, as well as two engine failure animations, triggered by collisions with the enemy. After one hit, the left engine begins to smoke; a second, the right begins to smoke; and after a third, fin.
C# Development | 如何使用 Chart 繪製折線圖，若資料量較多時可以使用滾動條查看折線圖
By: Garnett.C 嘎內
Tags: C Sharp Programming, Charts, Line Charts, Visual Studio, 嘎內學coding

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
Global Variables and Routines At Last
By: Troy Lyndon
Tags: Unity Game Development, C Sharp Programming, Gamedevhq

Although I suggest using private and public variables within the Monobehaviour class whenever possible, there are cases where using Global Variables and Routines make sense. In fact, it’s how Unity itself works!

That’s right, Debug.Log and Input.GetAxis are examples of routines we use in our code that are static.

The above example has a class name of “V”. In this way, I can access global variables like this: V.mode and routines like this: V.setMode(5).

So why did I finally break down and figure this out? I needed to create the 3rd item in my Core Programming todo list. To create numerous waves of enemies, this means that I need to create a game flow. First, GET READY! shows up. Then, WAVE #1 shows up. Then, the wave of enemies needs to be created, and so on and so forth.

To change from one task of the game flow to another, I have only one routine that is truly global SetMode(_).

Creating this structure was far more time consuming than I had thought it would be because I had to modify the existing game as it was, to follow this flow. But now, I feel that my code is clear, clean and will be easier to move forward with less concern for having to write 5 lines of code to access or change a variable in one script or another. With that said, my previous experiences as written about in my blogs still causes me to limit my use of the static class or variable to avoid other restrictions down the line.
Why the IgnoreAttribute not working in AutoMapper
Tags: Automapper, C Sharp Programming

Because IgnoreMapAttribute is the correct attribute for ignore mapping property not the IgnoreAttribute from AutoMapper.Configuration.Annotations
Generate PDF documents in .NET using PDFsharp
Tags: Pdf Generation, C Sharp Programming

Introduction

In this post, we will see how to create PDF documents in .NET using PDFSharp library.

PDFsharp is the Open Source .NET library that easily creates and processes PDF documents on the fly from any .NET language. The same drawing routines can be used to create PDF documents, draw on the screen, or send output to any printer.

PDFsharp and MigraDoc Foundation are published under the MIT License. You can see the details on this link.

Create Console Project

First, let’s create a .NET project. You can use Visual Studio or dotnet-cli for this purpose. I used following command to create a .NET Core console application:

dotnet new console

Install nuget packages

We also need to install nuget packages. Following are the packages you can install. However, if you download the code, then those are already added. You can simple restore the packages.

dotnet add package PdfSharp --version 1.50.5147 dotnet add package System.Drawing.Common dotnet add package System.Text.Encoding.CodePages //for .NET core

Code

This example code is taken from the PDFsharp website. However, I made some changes to get it working. For example notice that first statement where I am registering the Code-Pages encoding provider.

Output

And now if you open up the file, you will see that text is written in the file.

Summary

This was a very basic introduction of generating PDF using PDFsharp library. We saw that the API of this library is simple and it works well with .NET. There are a lot of other settings and options are available in this library, which you can check on the official webpage of PDFsharp.

The source code is of this example is available on this git-repo.

References
Write DRY Code Using Reflection
By: David Klempfner
Tags: C Sharp Programming, Software Development, Software Engineering, Dotnet Core, Programming

Write DRY Code Using Reflection

Photo by Elena Mozhvilo on Unsplash

In this article, I’ll show you a scenario where using Reflection can help improve the readability, maintainability, extensibility, and the DRYness of your code.

The Scenario

You’ve written a web app for a car dealership which prints reports about the cars in stock, and what cars have been sold.

Current State Of The Code

Here is what the code looks like at the moment. It’s a simple ASP.NET Core MVC application with one Controller called Home, and two classes for generating the reports.

The CarInfo class generates a report for the cars in stock:

The CarSales class generates a report for the cars that have been sold:

Running The App

The report type is sent as a query string in the URL.

If you run the app and navigate to https://localhost:<yourPortNumberHere>/Home/GenerateReport?reportType=CarSales you will see the output below:

You’ll get a similar report if you replace CarSales with CarInfo in the URL.

What’s Wrong With This Code?

The code works. But what if your boss asked you to add another report for the 2nd-hand cars the dealership has bought?

You’d need to add another else if block in the GenerateReport() method.

What if you needed to add more properties to the CarInfo or CarSale class like TransmissionType ? You’d need to add another set of 3 AppendLine() method calls in the DisplayReport() methods.

Imagine if the boss kept asking for more properties and more reports, the code would get larger and it would become a nightmare to maintain.

This code is not extensible, and does not adhere to the DRY principle because you would be repeating similar lines of code.

Improving It With Reflection

I’m going to use Reflection in two areas:

Working out what report class to use Displaying the properties of the CarSale and CarInfo objects

HomeController

In the HomeController , the class containing the logic for the report is instantiated based exactly on the value in the reportType string. No need for any if statements.

This has halved the number of lines of code!

CarInfo

Here we’re using Reflection to iterate through all the properties of the Car class. This means we no longer need to worry about adding more AppendLine() calls every time a new property is added to the class.

We now only have three calls to AppendLine() , instead of nine.

CarSales

The code change to CarSales is almost identical to CarInfo , and the benefits are exactly the same:

Summary

People tend to be scared of Reflection because it can be expensive. Most of the time, the performance hit is unnoticeable, and unless your application is performance critical, the benefits you get from readability, maintainability and extensibility far outweigh the performance hit from using Reflection.

Resources

The gists used in this article can be found here.
Day 7: A Coding Enigma
By: Brittany Lumanlan Martin
Tags: Internships, Gaming Articles, Game Development, Gamedevhq, C Sharp Programming

One week in, and it’s safe to say that I have officially run into my first real bump in the road. I have been stumped by something seemingly simple: a bug in my code to keep score.

Earlier on in the day, I finished up with the trio of powerups mentioned in my previous blog: the triple shot, speed boost and shield. Everything went well during my gameplay tests — from building my scripts to dropping in animations. Now, when the shield powerup is collected, a glowing blue shield visualizer appears to surround the players’ ship.

The next section I worked on was “User Interface (UI)”, by far my favorite section, because it’s the bridge between the game creator and player. It was quite cool to learn how to tie in code to animations for certain actions, like the flickering effect on the “GAME OVER” text shown in the recording of my game below.

You may have noticed that I do indeed have a score counter in the top right corner of the game, and, yes, at one point it was working! For every enemy ship destroyed, the player would collect 10 points and the “Score” text would update accordingly. The mystery I have yet to solve came about when I moved into the next section, “Effects (VFX)”. As of now, when the laser destroys the enemy and it explodes, the score doesn’t update. I spent an unimaginable time after work hours trying to debug the issue, but have not yet resolved it. I do believe it may come down to a typo I entered somewhere in the sea of C#. Hopefully after a solid night of rest, I’ll be able to tackle this in the morning. Until then, GAME OVER.
Building a Multiarch Microservice on .NET 5 and C# 9
By: Roberto Javier Yudice Monico
Tags: Net Core, Docker, Microservices, Net5, C Sharp Programming

Photo by Liam Briese on Unsplash

ARM CPU’s are no longer a mobile thing only. AWS has ARM-based instances which offer the same processing power and x86 based instance in most types of workloads often at a lower cost. Microsoft is roumored to release ARM instances soon, and Apple just released their M1 macbooks which use their ARM CPU that beats more expensive Intel-based Macbook on most workloads. At the current pace, ARM CPU’s are not only catching up but might soon overpass x86 CPU’s.

As ARM CPU continue to improve, running ARM and X86 applications in container workloads will become more common soon. Fortunately docker is already ready for this.

.NET 5 Multiarch images

Fortunately for us, Microsoft started publishing multiarch tags of .NET a while ago, so we already have a set of multiarch .NET 5 base images that we can work with.

The Microservice

We are going to build a simple microservice so that if you’d like you can deploy the multiarch images to your cluster and see how it works. We are going to use a very small microservice that only consists of two files, including the .csproj file.

The above will only compile on .NET 5, I’m using the new top-level statements feature of C# 9, which saves us some boilerplate code and makes it look cleaner and simpler.

Build the Docker image

For our microservice we are going to use a simple multistage build image. You will note that the Dockerfile doesnt change much — There is no reference to the multiarchitecture builld, this is because microsoft already publishes multiarchitecture images so Docker will automatically look for them based on the platforms that we pass in the arguments to the docker CLI, as you will see later.

Just to clarify a bit more on how Docker finds the base image that corresponds to the platform, if you go into the docker hub page for dotnet you will see that the arch of the image is always a string at the end of the image:

Using Docker buildx

Docker currently already supports docker images for multiple architectures, although it’s still an experimental feature that you have to enable in the settings.

Now that we have the Dockerfile we can build our multiplatform image. As mentioned before, this is an experimental feature, you can read more about it here, but first we will have to enable the experimental feature in the docker settings window:

After enabling them now you can run the following command to build you docker image:

docker buildx build --tag ryudice/net5-multiarch:latest --push --platform linux/arm64/v8,linux/amd64 .

I’m using my Dockerhub account there so if you want to publish the image replace it with the URL of your registry.

After the command finishes the image will show up in your registry and it should have two platforms: arm64 and amd64.

And there you go, now you can pull your image in your EKS Graviton instances or any other ARM platform.

You can find all the code for this article here.
Can C# 9.0 Outclass Python as a Scripting Language?
By: Sameeh Shkeer
Tags: Python, C Sharp Programming, Programming Languages, Scripting Language, Programming

Python shines as a scripting or glue language, not to mention Python is simple, easy to learn, and that the Zen design philosophy adds to its awesomeness and readability.

Whereas C#, is often popular for its versatility, robustness, and safety, coupled with the fact that it is counted among the most evolving languages nowadays.

C# 9.0 was officially released on the 10-Nov-2020; thanks to its Top-level statements feature, it is now a much more scripting friendly language.

Both Python and C# are High-Level, Object-Oriented, and General-Purpose languages.

Given these points, what are the major differences between both languages?

Interpreted vs. Compiled:

Python is an Interpreted language, while C# is a compiled one, which can count in favor of Python since there is no compilation step; the edit-test-debug cycle can be shortened.

However, we will see how C# can be compiled and executed in one step, turning this advantage into a tie.

Dynamically Typed vs. Statically Typed:

Python is dynamically typed, which means that variables do not have a type, but values do; in other words, you can give a Python variable an integer value and then give it a string value.

C#, on the contrary, is a Statically Typed language; hence all variables must be declared to be of a specific type.

With this in mind, let us see some real-world usages compared in both languages.

Prerequisites:

SDK

Python:

Python recent SDK(v 3.0 and above).

C#:

.NET recent SDK (v 5.0 and above).
About Datatypes
Tags: C Sharp Programming, Data Type, Programming

Hi guys its me again. Today I am writing about data types. Firstly I explain to whats the data types.

Data types, show us value assignment on C#. For example if we are b assign to 5, we should sequence write “int” to begin.

Int b = 5;

As your can see above, I am assign b to 5. In this way, I am never use 5. When I am write b, program will show me 5 on screen. I hope that example helped your understand this subject.

Now we can little serious. Data types can be examined on 4 branches for me. These are integers, float, string and char. I am show your most important data types. So lets start don’t late.

Okay lets start first and easier subject. Char data types will show us a letter. In this way, we don’t open up storage free on computer. Don’t forget, the program should always take up little space. Now lets look at the example.

char a;

As you can see above, I don’t assign a to number. Because we can’t assign number on char. Actually, the best way is to stop at this point.

All right then we second subject is string data type. String expressions are just consist of the words and no value use there. Lets look at the example

string a;

Actually string and char partially same. So I think I will pass the subject

And next subject is float expression. I am show us, most use expression on this subject. So I show your how to use double. Double most useful expression on float category. Lets look at the example.

double a=5.14;

Yep yep. Actually the only difference is that number is decimal. Don’t forget. We must put a period instead of a comma

And finally last subject. Integers expressions mostly same float. There is only difference is integers are not take a decimal number. We are usually use int but I am show you different 1 expression except int. Okay if your ready lets look at this.

Yeah the first expression is int. Int expression is take 32-bit value. And I most of the time use this expression. Don’t forget int take integer number value. So if you are write a=5.1 program crash.

int a=5 =>True

int a=5.1 =>False

I think your understand this point. So I pass.

And second and final expression. There is long. We are use if result is very big. So actually int and long are same. The only difference long value bigger than int. Okay if your understand lets look example.

long=5 =>True

long=5.1 =>False

Yep all of them this. I think your be very successful coder. Just fight subject and stay with software. See you different subject…