adapting a source script to a personnal code

Find quick help here to get you started with Hollywood

Re: adapting a source script to a personnal code

Postby Bugala » Thu Feb 19, 2015 8:10 pm

If you dont need pixel exact detection, then you could do the collision check based upon rectangle area.

Idea is that you know mousex and mousey, and you know crystal1x and crystal1y. plus you know the size of your mouse pointer and size of your crystals.

Then you could do:
Code: Select all
check = Collision(#BOX, mousex, mousey, mousewidth, mouseheight, crystal1x, crystal1y, crystal1width, crystal1height)
if check = TRUE  - - - collision happened.


This way you are checking virtual boxes if they are colliding or not with same locations as your mouse pointer and crystal are, effectively checking for real if those two are colliding, although, with a rectangle accuracy only.
Bugala
 
Posts: 569
Joined: Sun Feb 14, 2010 8:11 pm

Re: adapting a source script to a personnal code

Postby stefff285 » Sat Feb 21, 2015 12:36 pm

@allanon

hello my dear friend ! yes it is about the mouse pointer position and the sprite ! :)

@bugala

thank you so much ! yes it's better about the rectangle area :) thanx a lot i go scripting next week (wine on my linux laptop doesn't want to install hollywood right now, i go ask for on the dedicated forum



lot of thanx to both

kindly regards
User avatar
stefff285
 
Posts: 221
Joined: Sat Mar 03, 2012 1:59 pm
Location: dijon / france

Re: adapting a source script to a personnal code

Postby stefff285 » Thu Feb 26, 2015 7:26 pm

hello all hello allanon

so then i did that because i didn't found how to make (OnLeftMouseClick = ) or something as this

so this pure bad script wich is a beginning

Code: Select all
@DISPLAY {Width = 640, Height = 480, Title = "apng"}
@BGPIC 1, "decors-jay01.png"
@SPRITE 1, "sprite-kiokio-vrai.gif", {transparency = $ff0000}
@SPRITE 2, "sprite-jayblood-vrai.gif", {transparency = $ff0000}



Function p_mainloop()

   sprite1x = 640
   sprite1y = 480
   MoveSprite (2, sprite1x, sprite1y, MouseX(), MouseY())
EndFunction
SetInterval(1, p_MainLoop, 1000/50) ; 50fps

Repeat
   WaitEvent
Forever


in fact i would like to make the sprite go somewhere in the BG pic and stay, and yet and yet

i surrely have to make a fonction() just for this but as i am a noob could you pleas tell me how ?

thanx a lot

stéphane
User avatar
stefff285
 
Posts: 221
Joined: Sat Mar 03, 2012 1:59 pm
Location: dijon / france

Re: adapting a source script to a personnal code

Postby stefff285 » Thu Feb 26, 2015 8:17 pm

ooops

at first all both i have to thank you so much for all the help i ask you. to be true i'm totally a noob with this kind of code, i tried my day finding the good code to make "walk" the main sprite from a position and stop, and again and again but i think i go stay a gfx man in the demoscene :) so then bugala and allanon thank you so much, i follow your advices and go to render the enterly prod one day ^^

please accept my appologies if i seem lost, the fact is that i am ^^

regards
User avatar
stefff285
 
Posts: 221
Joined: Sat Mar 03, 2012 1:59 pm
Location: dijon / france

Re: adapting a source script to a personnal code

Postby stefff285 » Fri Feb 27, 2015 6:16 pm

ok i go see the asteroïd example and then understand what to do :)

see you soon
User avatar
stefff285
 
Posts: 221
Joined: Sat Mar 03, 2012 1:59 pm
Location: dijon / france

Re: adapting a source script to a personnal code

Postby Bugala » Fri Feb 27, 2015 11:24 pm

Not sure if you found the solution yet or not, but here is something for that walking that you could perhaps use. this is not real working code, but only part of it, but i think you can figure what i am after:

Code: Select all
function movecharacter(character)
n = character.n
curx = character.x
cury = character.y   
destx = character.destx
desty = character.desty
xtargetreached = character.xtargetreached   
ytargetreached = character.ytargetreached - - - These seven lines are just to make code easier to read, so that from now on we dont have to use "character.n", but we can instead just use "n"

if xtargetreached = FALSE     - - - This checks that if x target have been reached already, then it doesnt move character in x direction anymore, otherwise character will keep shaking one pixel left and right each time this line is executed.
   if curx =< destx
      curx = curx +1
      if curx => destx then xtargetreached = TRUE - - - Since we started for example from left side of the target, if we after movement are either on right side of it (the opposite site) or at same spot, then we know character have reached its target and can stop moving anymore in next cycle.
   else
      curx = curx-1
      if curx =< destx then xtargetreached = TRUE
   endif
endif

 - - - Either curx is smaller/same as destx or it is bigger than x, this way, all possibilites are gone through, and character will always either move one step left or right.

if ytargetreached = FALSE
   if cury =< desty
      cury = cury + 1
      if cury => desty then ytargetreached=TRUE
   else
      cury = cury - 1
      if cury =< desty then ytargetreached=TRUE
   endif
endif

displaylayer(n, curx, cury)  (draws the character in to its current location

character.curx = curx
character.cury = cury - - - saving current position for next cycles need.
character.xtargetreached = xtargetreached
character.ytargetreached = ytargetreached - - - y and x targets reached need to be memorised, so it knows not to execute movement towards x or y, if only one of them is reached yet.

if xtargetreached = true and ytargetreached=true
   return(TRUE)
else
   return(FALSE)
endif                   - - - When calling this function, it will return wether character have reached both its target co=ordinates or not yet, so you can do something else then.

ENDFUNCTION



FUNCTION SetDestination(character, targetx, targety)

character.destx = targetx
character.desty = targety
character.xtargetreached = FALSE
character.ytargetreached = FALSE

ENDFUNCTION

movingman1 = {n = 1, x = 600, y = 600, destx=1800, desty = 1600 }
movingwoman2 = {n = 2, x=300, y=200, destx=500, desty=500}

repeat

targetreached = movecharacter(movingman1)
if targetreached=true then SetDestination(movingman1, 400, 100)

movecharacter(movingwoman2)

until quit=TRUE





This is an non working example (as there are stuff missing from here), but idea would be that with this code there would be two characters moving on screen at same time, and when this movingman1 character would reach its destination, it would be given a new destination where to go after that.
Bugala
 
Posts: 569
Joined: Sun Feb 14, 2010 8:11 pm

Re: adapting a source script to a personnal code

Postby stefff285 » Fri Feb 27, 2015 11:37 pm

hello my dear bugala ! thank you so much :)
i go test it monday due to family meet since months (my brother and his wife and childrens joined us this afternoon so it's time to talk and drink :) )
you saved my night :)))

take care

stéphane
User avatar
stefff285
 
Posts: 221
Joined: Sat Mar 03, 2012 1:59 pm
Location: dijon / france

Re: adapting a source script to a personnal code

Postby stefff285 » Mon Mar 16, 2015 9:24 pm

hello bugala hello allanon hello andreas

hey yes mistake it seems. i tried your script under morphOS without error (seems to have to make a setinterval to make it work so then i have to see it) but in windows version of hollywood 6 the code at line 7 give me undefined symbol as the script has errors. but without any problem on morphOS it seems. so then i have to make the fonction works under amiga ng without any try under win32 ?

going to watch a movie and go back later to you amazing code

thanx a lot yet

stéphane
User avatar
stefff285
 
Posts: 221
Joined: Sat Mar 03, 2012 1:59 pm
Location: dijon / france

Re: adapting a source script to a personnal code

Postby stefff285 » Thu Mar 19, 2015 10:48 pm

okkkkkkkkkkkkkkkkkkkkkk :)
so then i 'm so a noooob in script that i prefered to do as this:
https://www.dropbox.com/s/3rf7bdfi3z1m2 ... s.zip?dl=0
for win32 and linux versions

so then i would like to make a simple scroll betwenn the two cristal things in one screen, behind the flower in the other screen using ttf topaz amiga fonts

anyone has a scrolltext source to tell me ? after all i have to make the allllll together and i believe i have simply to call differents fonctions as:
p_first()
p_second()
....

i go finish this prod and be proud about it even if my code is a lame and that i have to thanks allanon, bulaga and adreas for cool help

see you soon

stéphane
User avatar
stefff285
 
Posts: 221
Joined: Sat Mar 03, 2012 1:59 pm
Location: dijon / france

Re: adapting a source script to a personnal code

Postby Allanon » Fri Mar 20, 2015 12:43 am

Hi stefff,
I'm working on a demo engine with some interesting effects including scroll text, starfields, warp effects, mirrors, copper simulation, rainbow lines, twisters and many others with tweens and transitions support, if I've time I'll finish it and make a release, you could be interested in it :)
User avatar
Allanon
 
Posts: 345
Joined: Sun Feb 14, 2010 8:53 pm
Location: Italy

PreviousNext

Return to Newbie questions

Who is online

Users browsing this forum: No registered users and 1 guest