WARP from a point to another point in the same screen

Kajika

Member
Hello everybody,

my question is simple, i hope the answer is simple to ;)

i want to make few doors that warp in another place in the same screen, exemple:

i send you a picture for more explains, thank you very much

exemple-for-forum.png

https://imgshare.io/image/ltDUO
 

Mugi

Member
Code:
LDX player1_object
DeactivateCurrentObject
CreateObject #$10, #$20, #$00, #$02, currentNametable
TXA
STA player1_object
RTS
This will deactivate your player, and creates a new player in it's place in your desired coordinates.

the first argument (10) is the X coordinate (in pixles)
the second is Y coordinate
3rd is the object (object 00 is the player)
4th is the action state the object is in when it appears (set it to 00 for idle)
currentnametable is just a parameter used by the scroll engine.
 

Kajika

Member
Thank you very much fot your answer clear and quick!!

I m really newby about scripts. If i understood:
-i must create a new script nammed like i want
-i save it

but how can i "call" the script in the location that i want?


thks
 

Mugi

Member
you can make this a tile script, which will then activate when you touch it.
for that though, you will have to write some extra code to only make it react to the player, and not monsters or anything else that touches it.
and you will also have to write extra conditions for it to make the same tile usable in all 6 locations you have on your picture.
this is rather simple to to just by checking the current coordinates of the player and setting the new warp coordinates based on that.
 

Kajika

Member
thanks i think i understood.

For monster object, no problem because i want they can do it when they touch too.

For the 6 locations, i may be have a parade: in true i just need 4 tiles differents (see the img joined), i m going to create 4 scripts differents

What do yyou think about that?

https://imgshare.io/image/lDday
 

Mugi

Member
if you have tiletypes to spare, yeah, you could just make 4 different tilecodes and just use one for each door, but this can really be coded in so many ways that it ultimately just boils down to
how exactly you want to do it.

also, you will propably have to set up some kind of timer for the doors if you're going to make them activate simply by walking into them, or then you will have to set the "warp out" coordinate so that it will spawn you next to the door,
othervise when the player appears on the "exit" door, and touches it, it will simply instantly warp back, and get stuck in a loop :p
 

Kajika

Member
I chose the solution of 4 scripts, because it seems simple to me, my coding level is really very low (for now;))
moreover my game will run only on this image.
thank you for the tips, I would take it out a little further;)
 

Kajika

Member
May be Mugi you can help me another time:

i created the first script with your recommendations , and a modified like you can se in the screen a attribute for tile.

but.... i search and i dont find how define this attribute to call my script...
(i hope i explain cleary, because english is not my language, and it is difficult to explain subtlety)
 

Mugi

Member
you can go to your project settings, and scripts settings tab in nesmaker and assign new assembly files for your tile types.

pick one that is either empty or something you dont use on your game and replace the code with your own.

tiletypedefinitions.png


then when you make your assets in the screenpainter tool, use that tiletype to make your assets.
 

Kajika

Member
Thank you i did what you advised me, ... there is a reaction, but this not work.
When the player touch the tile , the player is flashing ( like if it disapear, but reapear at the same place.)

with all due respect, you who took your time to help me, would not he miss a thing in the code?
I ask you this so as not to waste time exploring many tracks for nothing, thanks again to you
 

Mugi

Member
well the code is not comple really, it just despawns the player and makes a new one, but you have to set the coordinates and what not for it.
i didnt really intend the code to be something that you can just copypaste and throw in really, it's just a general idea of how to do things.

learning is part of the fun in this business :)
 

Kajika

Member
I understood where the error came from.
the coordinates you gave me are in pixels, while I resonated with what the software displayed me.
he is doing well now!
I will prepare it properly, and then I will attack the AI ​​of my monster object :)

thanks again
 

Mugi

Member
no problem :)
i thought i did write into the post i made that the coordinates are pixels though :p
 

Kajika

Member
i saw that, it is why i found the error quickly. AT THE START I THOUGHT THAT it was a mistake on your part to talk about pixel

do you know a method to identify clerly?
 

Kajika

Member
Hello everyone and hello mugi if you read me again.
The script you gave me above taught me a lot but I'm stuck on an incomprehension, and I hope someone can help me:
so when I use the code, I choose a point for x and one for y.
the logic would like that my tiles having attribute this script after the disappearance make me reappear in the same place. but this is not the case, and I can not understand the logic of operation.
if you want more details pictured I can provide you that.
thank you for your attention, and I hope to find a solution, I test my side different things but I post this message because I lose my footing.
thank you all
 
Top Bottom