samp.directory
← Scripts et bibliothèques

Southclaws/samp-virtual-canvas

This small library provides a `VirtualCanvas` structure which represents a rectangle and a resolution. The canvas can be used to create a virtual space where coordinates can be scaled within that space.

Bibliothèque★ 2mis à jour févr. 2018Pas de licencePAWNsampctlArchivé
Ouvrir sur GitHub

L’auteur a archivé ce dépôt, il n’est donc plus maintenu.

Ce dépôt n’a pas de fichier de licence. Il est public en lecture, mais cela ne donne pas à lui seul le droit de le réutiliser.

Installer avec sampctl

sampctl package install Southclaws/samp-virtual-canvas

Lance ceci dans le dossier de ton projet. sampctl télécharge le paquet et ce dont il dépend.

L’essayer dans le compilateur Pawn →

Ajoute ses fichiers include, avec les bibliothèques dont il dépend, au compilateur Pawn de ton navigateur, prêts à être inclus dans un script.

Dépend de 1 paquet

README.md

virtual-canvas.inc

This small library provides a VirtualCanvas structure which represents a rectangle and a resolution. The canvas can be used to create a virtual space where coordinates can be scaled within that space.

This was originally written for bitmap scaling so a bitmap of size 1000x1000 pixels could be used to represent the entire San Andreas map and pixel coordinates could be mapped to world coordinates. This was needed because the game's world occupies a space that runs from -3000.0 X and -3000.0 Y to 3000.0 X and 3000.0 Y.

Installation

Simply install to your project:

sampctl package install Southclaws/samp-virtual-canvas

Include in your code and begin using the library:

#include <virtual-canvas>

Usage

Create a virtual canvas variable:

new canvas[VirtualCanvas];

Either fill it manually or use the helper function:

CreateVirtualCanvas(-3000.0, 3000.0, -3000.0, 3000.0, 1000, 1000, canvas);

This creates a canvas for the entire San Andreas map with a resolution 6 times smaller than the map at 1 metre scale.

Now you can retrieve coordinates from within the 0..1000 space and they are scaled up to the -3000..3000 space.

GetVirtualCanvasPos(canvas, 500, 500, x, y); // This stores the coordinates 0.0, 0.0 into x and y.
GetVirtualCanvasPos(canvas, 250, 250, x, y); // This stores the coordinates -1500.0, -1500.0 into x and y.
GetVirtualCanvasPos(canvas, 750, 750, x, y); // This stores the coordinates 1500.0, 1500.0 into x and y.

Testing

To test, simply run the package:

sampctl package run

And observe the output. Play with the values in test.pwn.

Cette page est construite à partir de ce que GitHub publie sur le dépôt. samp.directory n’héberge pas le code. Signaler un problème avec cette fiche

Southclaws/samp-virtual-canvas : Bibliothèque SA-MP | samp.directory