Jasper IT https://pietropassarelli.com/ IT school Tue, 29 Aug 2023 12:40:55 +0000 en-US hourly 1 https://wordpress.org/?v=6.3 https://pietropassarelli.com/wp-content/uploads/2023/08/cropped-letters-451503_640-32x32.jpg Jasper IT https://pietropassarelli.com/ 32 32 5 engines for creating games in Python https://pietropassarelli.com/5-engines-for-creating-games-in-python/ Tue, 29 Aug 2023 12:24:30 +0000 https://pietropassarelli.com/?p=141 Many people want to learn programming to create their own game. But what do you need and what do you need to learn in Python? The answer is game engines or libraries that exist for creating games in Python Libraries can be installed from different channels, such as GitHub or the pip manager. In addition […]

The post 5 engines for creating games in Python appeared first on Jasper IT.

]]>
Many people want to learn programming to create their own game. But what do you need and what do you need to learn in Python? The answer is game engines or libraries that exist for creating games in Python

Libraries can be installed from different channels, such as GitHub or the pip manager. In addition to them, there are standalone game development environments. Let’s take a look at the top 5 Python Game Engines.

PyGame
Probably the most popular engine chosen by most Python programmers is PyGame. It is implemented on the basis of the SDL library (Simple DirectMedia Layer), which allows you to open cross-platform access to various system components. For example, video devices, a keyboard, a mouse, audio systems, etc. The engine is also used to create various applications.

Pygame is essentially a set of tools for creating game objects, processing user input, and outputting graphics and sound. And due to the many components that make up the engine and several autonomous concepts, it is possible to implement projects on any system. The only condition is that they must be compatible with the library.

PyGame Zero
Pygame Zero is a newer and easier to learn engine option. It is ideal for beginners in the world of game development. A simple interface and step-by-step instructions are a great way to quickly learn how to develop 2D games. The Zero version does not delve into the jungle of complex terms and functions. Beginners can freely create whatever they need in a format where only the design and logic of the future game are important.

Adventure Lib
If you want to create text-based games or interactive stories like Zork, adventurelib is the best engine for you. This module is perfect for the console program format, providing a wide range of tools. With it, you can write everything from the character to the game logic. And thanks to the open source code and the absence of the need to write a parser, it is even easier to interact with it.

Ren’Py
Another type of game is novels or, as they are called, visual novels. They have a very important plot, and they perfectly dilute it with visuals and sounds. To implement them with Python, it is worth using the cross-platform Ren’Py programming environment. The name literally translates from Japanese as romantic love. In fact, after installation, the programmer will receive a working engine for creating games with all the necessary components. Moreover, they can be launched on different platforms.

But it is worth noting that since Ren’Py is not a classic library, it cannot be installed via pip install. You need the Ren’Py SDK.

Panda 3D.
A free engine for implementing 3D games and visualization in three-dimensional graphics called Panda 3D is filled with a huge number of working tools. It is perfectly compatible with various operating systems and runs even on mobile devices. The engine is a complete platform for the realization of both games and applications. Thanks to the support of a large number of resources and integration with many libraries, it is very convenient to work with Panda 3D.

The post 5 engines for creating games in Python appeared first on Jasper IT.

]]>
Improving JavaScript code: top 6 best practices https://pietropassarelli.com/improving-javascript-code-top-6-best-practices/ Sun, 20 Aug 2023 12:36:03 +0000 https://pietropassarelli.com/?p=144 The world of frontend development is rapidly changing, new libraries and frameworks are appearing, and the development process is improving and simplifying. It is very difficult to keep up with all the innovations. We’ve gathered 6 relatively new lifehacks that will improve your code in JavaScript. Optional SequencesTo access the properties of nested objects, even […]

The post Improving JavaScript code: top 6 best practices appeared first on Jasper IT.

]]>
The world of frontend development is rapidly changing, new libraries and frameworks are appearing, and the development process is improving and simplifying. It is very difficult to keep up with all the innovations.

We’ve gathered 6 relatively new lifehacks that will improve your code in JavaScript.

Optional Sequences
To access the properties of nested objects, even if some of them are missing, you can use option sequences. This is a new feature, so you’ll need to use polyfil to access it in older browsers.

Option sequences – make code cleaner and shorter. They allow you to quickly detect the absence of a property without having to manually search for it. In addition, they do not remove the exception, but return it as undefined.

Example:

const someObject = {
	profile: {
		firstName: 'Nicky',
		lastName: 'Christensen',
		country: 'Denmark'
	}
}

// Example 1 // with optional sequences:
if (someObject?.profile?.firstName){
	console.log('Name is 1: ', someObject.profile.firstName)
} // safe navigation through the object graph

// Example 2 // the old way without optional sequences:
if (someObject && someObject.profile && someObject.profile.firstName){
	console.log('Name is 2: ', someObject.profile.firstName)
}

// optional chains do not work because name does not exist:
if (someObject?.profile?.name){
	console.log('Name is 3: ', someObject.profile.firstName)
}// safe navigation through the object graph

Conclusion: Example 1 outputs only 2 console.log() in the form of Name is 1 and Name is 2, but Name is 3 does not, because it is absent in the profile.

In Example 2 without using optional sequences, you can see that the code is larger and more complex.

Zero merge operator
In cases when the ||| operator is used to set the standard value of the foo variable and false-like objects are considered appropriate – there is a risk of incorrect behavior. To avoid such situations, the null merge operator ?? appeared. It refers to logical operators that return the value of the right operand if the left operand contains null, undefined or any other false-like value. Under other conditions, it simply outputs the value of the left operand.

Example:

const falsy = false;
const emptyString = '';
const nullish = null;
const uDefined = undefined;
console.log('1', falsy ?? 'Some string');
console.log('2', emptyString ?? 'Default string')
console.log('3', nullish ?? 'Default string')
console.log('4', uDefined ?? 'Default string')
console.log('-------');
console.log('1.1', falsy || 'Some string');
console.log('2.2', emptyString || 'Default string')
console.log('3.3', nullish || 'Default string')
console.log('4.4', uDefined || 'Default string')

Dynamic Import
ECMAScript introduced a more convenient dynamic import. Unlike static import, it loads modules asynchronously. A similar principle of code splitting has long been used with build tools. At the same time, dynamic import does not require specific scripts and works without writing script type=”module”.

Example:

let someAsyncModule = await import('/modules/my-module.ts');

Promise.allSettled()
The familiar Promise.all() proved itself as a method of returning all promises. But it did not show which ones were executed and which ones were not. The more modern Promise.allSettled()method returns only those promises that are completed, but leaves an array of all others for further action.

Example:

const promise1 = Promise.resolve("OK, I resolved");
const promise2 = Promise.reject("OH no, I was rejected");
const promise3 = Promise.resolve("After I was rejected");
Promise.allSettled([promise1, promise2, promise3])
	.then((results) => console.log(results))
	.catch((err) => console.log("error: " + err));

Spread operators
The twin of the rest operator is spread. It has the same syntax, but it is aimed at combining objects and arrays. Earlier its function was performed by array.concat, but spread is more convenient and easy to use. It stretches elements rather than collapsing them. It is also used to copy arrays.

Example for arrays:

const arr1 = [1,2,3];
const arr2 = [4,5,6];
const arr3 = [...arr1, ...arr2] //arr3 ==> [1,2,3,4,5,6]

Example for objects:

const basePerson = {
	name: 'Nicky C',
	country: 'DK'
}
const footballerPerson = {
	...basePerson,
	team: 'Man UTD',
	shirtNumber: '11'
}
console.log(footballerPerson)

Object destructuring
Using the object destructuring syntax, you can extract the values you need and write them into new values with minimal code.

Example:

const basePerson = {
	name: 'Nicky C',
	country: 'DK'
}
const footballerPerson = {
	...basePerson,
	team: 'Man UTD',
	shirtNumber: '11'
}
const {team, shirtNumber} = footballerPerson;
console.log(team, shirtNumber); //ManUtd, 11

The post Improving JavaScript code: top 6 best practices appeared first on Jasper IT.

]]>
The capabilities of the Java language: Power and Flexibility of Programming https://pietropassarelli.com/the-capabilities-of-the-java-language-power-and-flexibility-of-programming/ Sun, 30 Jul 2023 12:17:43 +0000 https://pietropassarelli.com/?p=138 The Java programming language is considered one of the most popular and widely used languages in the world. Let’s find out what it can do and what it is! Created by James Gosling and his team at Sun Microsystems in 1995, Java quickly became the standard for many industries, including web development, mobile applications, large […]

The post The capabilities of the Java language: Power and Flexibility of Programming appeared first on Jasper IT.

]]>
The Java programming language is considered one of the most popular and widely used languages in the world. Let’s find out what it can do and what it is!

Created by James Gosling and his team at Sun Microsystems in 1995, Java quickly became the standard for many industries, including web development, mobile applications, large enterprise systems, and embedded devices. One of the key factors behind its success has been its power and flexibility. In this article, we’ll take a look at the main features of the Java language that have made it so popular and in demand.

Some basic provisions


Platform Independence:
One of the unique features of Java is its ability to run on different platforms without changing the source code. This is achieved through the use of the Java Virtual Machine (JVM), which translates Java bytecode into machine code that is understood by a specific platform. Thus, Java-developed programs can run on Windows, macOS, Linux, and other operating systems without the need to rewrite the code for each platform.

Rich Standard Library:
Java comes with a large set of libraries (Java Standard Library), which provides many useful classes and methods for solving various tasks. Thanks to this, developers can quickly and efficiently create complex programs without having to write everything from scratch. Java libraries include functionality for networking, databases, graphics, multithreading, mathematical operations, and many other aspects of programming.

Multithreading:
Java has built-in support for multithreading, which allows you to create programs that can efficiently use multiple threads to perform different tasks in parallel. This is especially important in today’s world, where many systems and programs need to process many requests simultaneously. Multithreading improves performance and reduces the load on computer resources.

Exception Handling:
Java provides an exception handling mechanism that allows developers to handle errors and exceptions in the code. This increases application resilience and prevents critical failures from occurring because programs can gracefully handle errors at runtime.

Object-Oriented Programming (OOP):
Java fully supports object-oriented programming concepts such as inheritance, polymorphism, encapsulation, and abstraction. OOP allows you to create modular and reusable code blocks, which simplifies software development and maintenance. Thanks to OOP, Java is used in a variety of projects – from small applications to complex systems of large corporations.

Large Developer Community:
Java has a huge community of developers around the world. This means that you can always find help, solutions to problems, or updates through a variety of forums, blogs, articles, and other resources. The huge community also contributes to the development of many third-party frameworks and libraries that extend the functionality of the language.

Java Virtual Machine (JVM):
As mentioned earlier, the JVM plays an important role in making Java platform independent. However, the JVM also provides other benefits. For example, it provides automatic memory management (garbage collection), which allows developers to avoid having to manually allocate and free memory. The JVM also optimizes code execution while the program is running, increasing its performance.

A variety of Rich Development Tools:
There are many integrated development environments (IDEs) for developing Java programs, such as Eclipse, IntelliJ IDEA, and NetBeans. These tools offer a wealth of possibilities.

The post The capabilities of the Java language: Power and Flexibility of Programming appeared first on Jasper IT.

]]>