Skip to content

Commit

Permalink
update to version 0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ericoporto committed Oct 1, 2023
1 parent eeca6cd commit 9142808
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.BBCode
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[size=14pt][b]rellax[/b][/size] [color=gray][b]version 0.3.1[/b][/color]

[url="https://github.com/ericoporto/rellax/releases/download/0.3.1/rellax.scm"]Get Latest Release [b]rellax.scm[/b][/url] | [url="https://github.com/ericoporto/rellax"]GitHub Repo[/url] | [url="https://github.com/ericoporto/rellax/releases/download/0.3.1/rellax_demo_windows.zip"]Demo Windows[/url] | [url="https://github.com/ericoporto/rellax/releases/download/0.3.1/rellax_demo_linux.tar.gz"]Demo Linux[/url] | [url="https://github.com/ericoporto/rellax/archive/master.zip"]Download project .zip [/url]
[url="https://github.com/ericoporto/rellax/releases/download/0.3.2/rellax.scm"]Get Latest Release [b]rellax.scm[/b][/url] | [url="https://github.com/ericoporto/rellax"]GitHub Repo[/url] | [url="https://github.com/ericoporto/rellax/releases/download/0.3.2/rellax_demo_windows.zip"]Demo Windows[/url] | [url="https://github.com/ericoporto/rellax/releases/download/0.3.2/rellax_demo_linux.tar.gz"]Demo Linux[/url] | [url="https://github.com/ericoporto/rellax/archive/master.zip"]Download project .zip [/url]

Rellax while the camera tracks with cool parallax

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"name": "rellax",
"text": "Rellax while the Camera tracks with cool parallax.",
"forum": "https://www.adventuregamestudio.co.uk/forums/index.php?topic=57489.0",
"version": "0.3.1",
"version": "0.3.2",
"author": "eri0o"
}
67 changes: 47 additions & 20 deletions rellax.asc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Rellax
// 0.3.1
// 0.3.2
// A module to provide smooth scrolling and parallax!
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// Before starting, you must create the following Custom Properties
Expand Down Expand Up @@ -69,11 +69,18 @@ Character* _TargetCharacter;
Vec2* _TargetPos;

// Parallax objects
Object* _pxo[MAX_PARALLAX_OBJS];
int _pxoRoomStartX[MAX_PARALLAX_OBJS];
int _pxoRoomStartY[MAX_PARALLAX_OBJS];
int _pxoOriginX[MAX_PARALLAX_OBJS];
int _pxoOriginY[MAX_PARALLAX_OBJS];
struct ParallaxObject {
Object* Object;
int RoomStartX;
int RoomStartY;
int ObjectOriginX;
int ObjectOriginY;
bool HasParallax;
float ParallaxX;
float ParallaxY;
};

ParallaxObject _pxo[MAX_PARALLAX_OBJS];
int _pxo_count;

// Tween Stuff
Expand Down Expand Up @@ -429,12 +436,12 @@ void _r_do_object_parallax(){
int camy = FloatToInt(_next_cam_pos.y);

for(int i=0; i<_pxo_count; i++){
if(_pxo[i].GetProperty("PxPos") !=0 || _pxo[i].GetProperty("PyPos") != 0) {
float parallax_x = IntToFloat(_pxo[i].GetProperty("PxPos"))/100.0;
float parallax_y = IntToFloat(_pxo[i].GetProperty("PyPos"))/100.0;
if(_pxo[i].HasParallax) {
float parallax_x = _pxo[i].ParallaxX;
float parallax_y = _pxo[i].ParallaxY;

_pxo[i].X=_pxoOriginX[i]+FloatToInt(IntToFloat(camx)*parallax_x);
_pxo[i].Y=_pxoOriginY[i]+FloatToInt(IntToFloat(camy)*parallax_y);
_pxo[i].Object.X = _pxo[i].ObjectOriginX + FloatToInt(IntToFloat(camx)*parallax_x);
_pxo[i].Object.Y = _pxo[i].ObjectOriginY + FloatToInt(IntToFloat(camy)*parallax_y);
}
}
}
Expand Down Expand Up @@ -676,7 +683,7 @@ void set_TargetCharacter(this Rellax*, Character* target)

Character* get_TargetCharacter(this Rellax*)
{
return _TargetCharacter;
return _TargetCharacter;
}

void set_EasingType(this Rellax*, RellaxTweenEasingType value)
Expand Down Expand Up @@ -830,24 +837,44 @@ void doSetOrigins ()
float room_h = IntToFloat(Room.Height);

for(int i=0; i<Room.ObjectCount; i++){
if (object[i].GetProperty("PxPos")!=0) {
bool has_parallax = object[i].GetProperty("PxPos")!=0 || object[i].GetProperty("PyPos")!=0;

if (has_parallax) {
_pxo[_pxo_count].HasParallax = has_parallax;
// Store the object in the parallax object array
_pxo[_pxo_count] = object[i];
_pxo[_pxo_count].Object = object[i];
// Get the parallax values for the object, and it's position
float parallax_x = IntToFloat(object[i].GetProperty("PxPos")) / 100.0;
float parallax_y = IntToFloat(object[i].GetProperty("PyPos")) / 100.0;
float obj_x = IntToFloat(object[i].X);
float obj_y = IntToFloat(object[i].Y);

// store pre-calculated parallax_x and y
_pxo[_pxo_count].ParallaxX = parallax_x;
_pxo[_pxo_count].ParallaxY = parallax_y;

// Store the object's initial position for resetting later
_pxoRoomStartX[_pxo_count] = object[i].X;
_pxoRoomStartY[_pxo_count] = object[i].Y;
_pxo[_pxo_count].RoomStartX = object[i].X;
_pxo[_pxo_count].RoomStartY = object[i].Y;

// Calculate the origin position for the object
_pxoOriginX[_pxo_count] = object[i].X - FloatToInt(parallax_x * obj_x * (room_w - cam_w) / room_w);
_pxoOriginY[_pxo_count] = object[i].Y - FloatToInt(parallax_y * obj_y * (room_h - cam_h) / room_h);
_pxo[_pxo_count].ObjectOriginX = object[i].X - FloatToInt(parallax_x * obj_x * (room_w - cam_w) / room_w);
_pxo[_pxo_count].ObjectOriginY = object[i].Y - FloatToInt(parallax_y * obj_y * (room_h - cam_h) / room_h);

if(_pxo_count<MAX_PARALLAX_OBJS) _pxo_count++;
}
}

for(int i=_pxo_count; i<MAX_PARALLAX_OBJS; i++){
_pxo[i].Object = null;
_pxo[i].HasParallax = false;
_pxo[i].ParallaxX = 0.0;
_pxo[i].ParallaxY = 0.0;
_pxo[i].RoomStartX = 0;
_pxo[i].RoomStartY = 0;
_pxo[i].ObjectOriginX = 0;
_pxo[i].ObjectOriginY = 0;
}
// Apply the parallax effect to the objects
_r_do_object_parallax();
}
Expand Down Expand Up @@ -880,8 +907,8 @@ function on_event (EventType event, int data){
{ // player exits any room
// reset the parallax object positions
for(int i=0; i<_pxo_count; i++){
_pxo[i].X=_pxoRoomStartX[i];
_pxo[i].Y=_pxoRoomStartY[i];
_pxo[i].Object.X = _pxo[i].RoomStartX;
_pxo[i].Object.Y = _pxo[i].RoomStartY;
}
_roomSetupDone = false;
}
Expand Down
2 changes: 1 addition & 1 deletion rellax.ash
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Rellax
// 0.3.1
// 0.3.2
// A module to provide smooth scrolling and parallax!
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// Before starting, you must create the following Custom Properties
Expand Down
Binary file modified rellax.scm
Binary file not shown.
2 changes: 1 addition & 1 deletion rellax.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<Name>rellax</Name> <!-- set the module name -->
<Description>Rellax while the Camera tracks with cool parallax.</Description> <!-- set the module description -->
<Author>eri0o</Author> <!-- set the module author -->
<Version>0.3.1</Version> <!-- set the module version -->
<Version>0.3.2</Version> <!-- set the module version -->
<Key>1909973127</Key> <!-- set the module unique key -->
</AGSModule>

0 comments on commit 9142808

Please sign in to comment.