2D Scale/Zoom

A forum to share your demonstrations stacks, fun stacks, games, etc.
Post Reply
xAction
Posts: 285
Joined: Thu Sep 16, 2021 1:40 pm
Contact:

2D Scale/Zoom

Post by xAction »

Scale_2D_Points.oxtStack
(26.71 KiB) Downloaded 19 times
Scale_2D_Points.gif
Scale_2D_Points.gif (71.01 KiB) Viewed 101 times
This demonstrates scaling (or zooming) and scrolling a bunch of 2D coordinates without using a group.

Oh now that I think about it maybe I should have put all the points into a grid instead of random locations for the demonstration. oops.

The created objects are called "base" for lack of a better word when making a Turn Based (or real time) Strategy Game.
In a game (this is not a game) Bases produce Units of various types, as opposed to say a Rendezvous point where all the Units might group up or a Resource that just has some property value that can be transferred to Units. Bases are targeted by enemies to take over sectors of the map and produce reinforcements from their newly seized base.

You can use the concepts in this script for producing something like a big space action game, where things are set to spawn off the map and maybe patrol/menace that location until the player gets there (via scrolling) , while developing you can zoom out to check out how things look, or you might have sprites in diverse locations with far off screen coordinates like 10000,10000 be represented by simple graphics in a mini-map at 10,10.

This stuff is built into every web browser and image viewer/editor (even the Mac desktop!) so I'm surprised it's not default programming tutorial material.

Oh the random 'base' generator also demonstrates Stocastic Processes and Probability Distribution, I'll let Bing CoPilot explain that:
Stochastic Processes:
A stochastic process (also known as a random process) is a mathematical concept that involves a sequence of random variables indexed by time or some other parameter.
These random variables represent the evolution of a system or phenomenon over time, where each value is subject to randomness.
Stochastic processes are used to model systems that exhibit variability or randomness, such as stock prices, temperature fluctuations, or the behavior of particles in a gas.

In your case, the two random numbers with certain conditions before a process continues can be thought of as a simple form of a stochastic process.

Example:
Suppose you have a process where you need to generate two random numbers, and you want them to satisfy a specific condition (e.g., fall within a certain range).
You can define a stochastic process that generates these random numbers according to the desired condition.
For instance, if you’re reducing the probability of an event (such as hitting a specific target), you can use a stochastic process to control the randomness while ensuring the numbers fall within the desired range.

Probability Distributions:
To achieve this, you’ll likely work with probability distributions. These distributions describe the likelihood of different outcomes for a random variable.
For example, if you want your random numbers to follow a uniform distribution within a specific range, you can sample from a uniform distribution.
Similarly, other distributions (such as normal, exponential, or Poisson) can be used based on the specific conditions you need to satisfy.

Remember that stochastic processes provide a powerful framework for modeling randomness and uncertainty in various fields, including programming, finance, and natural sciences. So, when you encounter situations like the one you described, consider exploring stochastic processes and probability distributions to handle randomness effectively!
All that AI image generation that's so popular is using these same processes.
xAction
Posts: 285
Joined: Thu Sep 16, 2021 1:40 pm
Contact:

Re: 2D Scale/Zoom

Post by xAction »

Scale_2D_Points_SelectedObject.oxtStack
(122.9 KiB) Downloaded 19 times
Scale_2D_Points_centered_on_selection.gif
Scale_2D_Points_centered_on_selection.gif (391.84 KiB) Viewed 83 times
This new stack demonstrates how to zoom in and out on a selected object's location.

Zooming on selection is abrupt and not very obvious in with random bases so I I've turned the map into an even more enormous grid for demonstration purpose, via Init.GridBases.

If you are doing a lot of mouse wheel zoom in your game then it's probably unwieldy in that state.
Maybe some shift key modifier would work better for when you want to scale real fast.

You can reset the map to random or grid base with right click pop up menu.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests