adapting a source script to a personnal code

Find quick help here to get you started with Hollywood
User avatar
stefff285
Posts: 230
Joined: Sat Mar 03, 2012 12:59 pm
Location: dijon / france
Contact:

Re: adapting a source script to a personnal code

Post by stefff285 »

hahaaaaaaaaaaaaaaaaaaaaa ! for sure ! love your work already ^^ thanx so much for help but i have to find how to make simple scroll text with ttf or i go take an existing scroll text and put my gfx ;) ok i'm a noob and stills loving demos but i'm definitly not a coder ^^ so many regards to you !!
User avatar
stefff285
Posts: 230
Joined: Sat Mar 03, 2012 12:59 pm
Location: dijon / france
Contact:

Re: adapting a source script to a personnal code

Post by stefff285 »

ok ! i did this but actually :

Code: Select all

@VERSION 2,0

/*
** external data
*/
@SCREEN {Mode = "ask", Width = 640, Height = 480}
@BRUSH 1, "jayblood-menu-up3.png", {transparency = $ff0000}
@BGPIC 1, "decors-jay01.png"
@SPRITE 2, "sprite-jayblood2.gif", {transparency = $ff0000}
@BRUSH 2, "fleur-grosse.png", {transparency = $0000ff}
@BRUSH 3, "Chars2.png", {Transparency = True}

/*
** inits the cosine wave
*/
Function p_InitWave()

	For Local k = 0 To 230
		S! = S! + 0.08
		Y[k] = 450 + Cos(S!) * 10
	Next

EndFunction



/*
** inits the scroll text and brushes + positions for it
*/
Function p_InitText()

	Local x, ypos = 0, 0

	For Local k = 0 To 19 Do XP[k] = k * 18 - 19

	Local SCN$="!ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.: "
	Local TE$="                    WELCOME TO SOME SINUS TEXT DONE WITH HOLLYWOOD. THIS CODE USES THE NEW " ..
	"DOUBLEBUFFERING FUNCTIONS TO CREATE A SMOOTHLY ANIMATED DISPLAY. CHECK OUT THE HOLLYWOOD MANUAL " ..
	"FOR MORE INFORMATION. GREETINGS TO ALL FELLOW AMIGA USERS....................................................."

	For Local k = 0 To StrLen(TE$) - 1
		I[k] = FindStr(SCN$, MidStr(TE$, k, 1))
	Next

	I[StrLen(TE$)] = -1

	; init lookup table for character positions
	chars = {}

	For Local k = 1 To 39

		chars[k] = {x = x * 14, y = ypos}

		x = x + 1
		If x = 12
			x = 0
			ypos = ypos + 14
		EndIf
	Next

EndFunction

Function p_Scrollmain()

	
	

	
	DIS = DIS - 3
	If DIS = 0
		DIS = 18
		POS = POS + 1
		TEX = Wrap(TEX + 1, 0, TL)
	EndIf

	/* Render scroll text! */
	For Local k = 0 To 19
		tmp = k + TEX

		If I[tmp] = -1
			TEX = 0
			tmp = 0
		EndIf

		DisplayBrushPart(3, chars[I[tmp]].x, chars[I[tmp]].y, XP[k] + DIS, Y[POS + k], 14, 14)
	Next

	POS = Wrap(POS - 1, 0, 157)

EndFunction

Y = {}
XP = {}
I = {}
SP = {}
XS = {}
YS = {}
CL = {}

p_InitWave()
p_InitText()

DIS = 18


DisplayBGPic(1)

Function p_mainloop()
DisplayBrush(1, 0, 0)
p_Scrollmain
DisplayBrush(2, 0, 360)
DisplaySprite(2,520,150)
EndFunction

SetInterval(1, p_MainLoop, 1000/50) ; 50fps


Repeat
   WaitEvent
Forever
and my result is this with win 32 compile

https://docs.google.com/uc?id=0B2WMMDCg ... t=download

the scroller isn't good at all, no good transparency :((

i changed the fonts background to an alpha one so now it's alpha = true instead of black

thanx a lot for help

regards

stéphane
User avatar
Allanon
Posts: 732
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: adapting a source script to a personnal code

Post by Allanon »

Hi stefff,
can you share your source code along with the resources used so I can have a look at it? :)
User avatar
stefff285
Posts: 230
Joined: Sat Mar 03, 2012 12:59 pm
Location: dijon / france
Contact:

Re: adapting a source script to a personnal code

Post by stefff285 »

hello allanon

of course i go make a folder on a google drive to pm it to you after

regards :) thanx a lot
User avatar
stefff285
Posts: 230
Joined: Sat Mar 03, 2012 12:59 pm
Location: dijon / france
Contact:

Re: adapting a source script to a personnal code

Post by stefff285 »

hi allanon bugata and all

now i have all the sources to make an unique function ! but i still have a problem:
at compilig for windows, no problem to execute my two sources with mp3 choice but when exporting from gui (on morphOS) the same on linux x86, the exe ask me for mp3 codec it seems. so i did it on a past prod but i don't remember how to fix it. i mean perhaps have i to put the AVCODEC.hws next to the linux exe ?

another point: in the main function making works all function included before, i would like to stop a function by a key to go to the following one. i looked at pdf documentation but i didn't found the right commande ?

thanx a lot allanon, bulaga and all about this prod, be sure to be greets and loved ^^

kindly regards

yogib33r
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Re: adapting a source script to a personnal code

Post by Bugala »

If i understood your question right, then I think you have misunderstood usage of functions a bit.

For it sounded like what you are hoping is that you press "a" and function 1 is played, you push "b" and function 2 starts playing without any problems.

However, to compare it to child playing in a house, the thing is.

Child plays in room 1, makes a mess to the room. Then he moves to room 2, and room 1 still stays a mess.
If he then moves back to room 1, not only will room 2 be a mess as well, but in addition, when he moves to room 1, that room is already a mess, so it wont start from beginning.

However, there is one big difference between a Hollywood program/function (or any other languages as well), in that there are no separate rooms, but each play is actually played in same room.
You could think that child has a playroom, and first room 1 is teleported to that playroom, and child can play tehre and make that mess. And when he chagnes room to room 2, instead of child moving there, the room 1 is teleported to warehouse as it is, and room 2 is teleported to playroom. Then when again changing back to room 1, room 2 is teleported to warehouse, and room 1 is teleported from warehouse back to playroom, as it was originally saved to warehouse.

Hence what you are looking for, is to make them functions in such way, that they are all independent in practice.

One possiblity would then be for example "ClearScreen" command. Every function could start with this, practically cleaning the room (at least from graphics), but remember that all the variables that were changed in previously executed functions, still contain their states (As example. A=2) and they are not resetted, unless you yourself make such a thing at beginning.

That you could have for example by making each function starting with:

Code: Select all

A=0
B=0
C=0


effectively resetting those variables back to 0, instead of keeping their information.


All in all, there are many ways to approach and solve this problem, but there is no magic button to switch from one function to another and just work, unless the function itself is such.

For example if function is simply "print("hello world!")" then that isnt really much problem even if you jump to there from fly.


One way to get the actual function ewxecution functionality would be to use for example following way:

Code: Select all

function one()
print("one")
endfunction


function two()
print("two")
endfunction

fst = {} /* fst = Function States Table
fst.one = false
fst.two = false


repeat

if fst.one = true then one()
if fst.two = true then two()

if iskeydown("a") = true 
   fst.one=true
   fst.two=false
elseif iskeydown("b") = true
  fst.one=false
  fst.two=true
endif

forever
Idea with this is, that you control yourself which loops are being executed. You push key "a" and function one will bne executed, but every other function will be stopped from executing as their TRUE states are changed to fault.
Naturally this could be done so that even more than just one function are being executed each loop, but in this example i just put two functions, from which only one is being executed.

When you alter the fst.one or fst.two states to TRUE or FALSE, it changes wether these functions are executed as they are executed only when they are in true state.
User avatar
stefff285
Posts: 230
Joined: Sat Mar 03, 2012 12:59 pm
Location: dijon / france
Contact:

Re: adapting a source script to a personnal code

Post by stefff285 »

oua ! thank you bugala . i need more time to understand what to do with your help because the fact is i'm definitly not a coder. so then i have to understand more what you said. the "choice" code you gave me need to be understood by my humble person :D thank you so much. regards
User avatar
stefff285
Posts: 230
Joined: Sat Mar 03, 2012 12:59 pm
Location: dijon / france
Contact:

Re: adapting a source script to a personnal code

Post by stefff285 »

hello bulaga and all and allanon

so i been spoke about a solution as clear interval ? does it need too to stop the processus as the mess you spoke me ?
this i actually the solution i go to use because as a noob, your solution necessite me so many studies that i think i go try this one

regards
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Re: adapting a source script to a personnal code

Post by Bugala »

If i understood correctly what you were asking. Then here is the interval version of that previous example i gave to you:

Code: Select all

function one()
print("one")
endfunction


function two()
print("two")
endfunction

function keypresses()

if iskeydown("a") = true
   setinterval(1, one(), 40)
   clearinterval(2)
elseif iskeydown("b") = true
  setinterval(2, two(), 40)
  clearinterval(1)
endif

endfunction


setinterval(3, keypresses(), 40)


repeat
waitevent()
forever

notice that this isnt really a working code.

There are couple of errors in this.

1. when you press for example "a", while it will make the interval 1, it will also try to clear interval 2, which isnt existing at beginning yet.

You could fix this by setting interval 2 before going to repeat-forever loop.

2. Even if you would fix this problem, then there would still be the problem that you couldnt for example push "a" key twice, since at second press it would try to be setting up interval 1 again, which is already existing, as well as trying to clear interval 2, which was already cleared witht he first press. By other words, only way to have it work right, would be to keep pushing "a" and "b" right after each other, instead of pushing same button twice.


By otherwords, to make this truly working, you would need to make some control things there, like checking if interval 1 is already existing, before making interval 1, or checking if interval 2 is existing, before trying to clear it.

I left these controlling parts out, so code would be more clear to read, since you can find out the principle of how it could go even from this non working code.


Idea is that interval 3 (keypresses() function) is continuously being executed. This is done because when at waitevent(), program wont continue forward at all, and only things being passively executed, are these interval things while waiting for some Event to happen to get past the waitevent().

This keypresses function is the function in where it checks if "a" or "b" from keyboard are being pressed, and if it is, then it will clear the other interval away (by other words, stops executing the other function) as well as starting the other interval (starts executing the other function)
User avatar
stefff285
Posts: 230
Joined: Sat Mar 03, 2012 12:59 pm
Location: dijon / france
Contact:

Re: adapting a source script to a personnal code

Post by stefff285 »

thank you so much i go try this when the last effects will be scripted and working

see you :)
Post Reply