Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, TedMar), 1,031 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: How to make pulsating text? [Re: 4gottenname] #271589
06/14/09 02:05
06/14/09 02:05
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Heres a new code thats "basically" the same, but now the texts only pulsate when the mouse is over the button.
(note: my using "toggle" buttons is required, not a typo)

Any questions? Ask away, otherwise enjoy!
Click to reveal..
Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////
BMAP* backgroundpergament_tga = "backgroundpergament.jpg"; // background image 800x600
BMAP* transparentbutton = "#210x40x32";		//create temporary black image for button
FONT* normal38_font = "Arial#38"; // was using a cooler font here
FONT* medium44_font = "Arial#44"; // but it's uncommon so changed
FONT* large50_font = "Arial#50";  // it to standard boring arial...
////////////////////////////////////////// START ///////////////////////////////////////
PANEL* start_panel = // the first panel. will show at game start up
{
	layer = 1; 
	pos_x = 250;	pos_y  = 180;
	bmap = backgroundpergament_tga;	
	size_x = 300;	size_y = 300;	// just resizing so you can see where panel edges are.
	button_toggle(50, 20 , transparentbutton, NULL, NULL, NULL, NULL, pulsate_text_stop, pulsate_text);
	button_toggle(50, 120, transparentbutton, NULL, NULL, NULL, NULL, pulsate_text_stop, pulsate_text);
	button_toggle(50, 220, transparentbutton, NULL, NULL, NULL, NULL, pulsate_text_stop, pulsate_text);
	flags = SHOW;	//OVERLAY | SHOW;   just disabled OVERLAY so you can see where panel edges are.
}
//
//
TEXT* newgame_txt =
{
	pos_x = 405;	pos_y = 200;
	layer = 2;		font = normal38_font;
	red = 255;		green = 255;		blue = 190;
	string = "New Game";
	flags = CENTER_X | CENTER_Y | SHADOW | SHOW;
}
TEXT* loadgame_txt =
{
	pos_x = 405;	pos_y = 300;
	layer = 2;		font = normal38_font;
	red = 255;		green = 255;		blue = 190;
	string = "Load a Game";
	flags = CENTER_X | CENTER_Y | SHADOW | SHOW;
}
TEXT* options_txt =
{
	pos_x = 405;	pos_y = 400;
	layer = 2;		font = normal38_font;
	red = 255;		green = 255;		blue = 190;
	string = "Configuration";
	flags = CENTER_X | CENTER_Y | SHADOW | SHOW;
}
////////////////////////// FUNCTION MAIN /////////////////////////////////
function main()
{
	video_mode = 7; // 800x600
	mouse_mode = 1;
	level_load("");	//   just to display blue background so you can see where panel edges are.
	wait (1);
	while (1)
   {
      mouse_pos.x = mouse_cursor.x; // need these to move the cursor
      mouse_pos.y = mouse_cursor.y;
      wait (1); 
      if(key_cuu)	{	loadgame_txt.pos_x -= time_step*2;	diag_var("pos_x=%.0f;\n", loadgame_txt.pos_x);	}
      if(key_cud)	{	loadgame_txt.pos_x += time_step*2;	diag_var("pos_x=%.0f;\n", loadgame_txt.pos_x);	}
   }
}
//////////////////////////////////////////////////////////////////////////
//
function pulsate_text_stop(var,PANEL*);
//
function pulsate_text(var butt_over, PANEL* this_pan)
{
	proc_kill((void*)pulsate_text);
	pulsate_text_stop(butt_over, this_pan);	//reset all text sizes for this panel
	//
	TEXT* this_text;
	switch(butt_over)
	{	
		case 1:		this_text = newgame_txt;
		case 2:		this_text = loadgame_txt;
		case 3:		this_text = options_txt;
	}	
	//
	while(1)
	{
		this_text.font = medium44_font;		wait (-0.2);
		this_text.font = large50_font;		wait (-0.2);
		this_text.font = medium44_font;		wait (-0.2);
		this_text.font = normal38_font;		wait (-0.2);
	}
}
//
function pulsate_text_stop(var butt_left, PANEL* this_pan)
{
	proc_kill((void*)pulsate_text);
	//
	TEXT* this_text;
	switch(butt_left)
	{	
		case 1:		this_text = newgame_txt;
		case 2:		this_text = loadgame_txt;
		case 3:		this_text = options_txt;
	}	
	//
	if(this_text.font==large50_font)	{	this_text.font = medium44_font;		wait (-0.2);	}
	if(this_text.font==medium44_font)		this_text.font = normal38_font;
}




NOTE :: What I said before about using bmap_fill to changes the bmap colors doesnt work so simple with panels.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: How to make pulsating text? [Re: EvilSOB] #271651
06/14/09 10:25
06/14/09 10:25
Joined: Jun 2009
Posts: 22
Finland
4gottenname Offline OP
Newbie
4gottenname  Offline OP
Newbie

Joined: Jun 2009
Posts: 22
Finland
Awsome, you made it work! laugh
A bit tierd today, was gona ask something realy stupid (why they stop working when changing panel size, DUH! /facepalm). Will use your first code for my menu panels with 3-5 options that are placed under each other and this for the other cases when buttons are placed futher away from each other. smile

I do have a few questions... What's the purpose of this line:
function pulsate_text_stop(var,PANEL*);
I read you can have many functions with the same name and diffrent parameters but that first one don't seem to do anything. When is it called or are both pulsate_text_stop functions called at same time? /confused

Then a question about the panel pointer. Maybe you would had mentioned or added it already if it was possible but I ask anyway. Could I add a if comparison to the switch code to check if this_pan(the pointer) == start_panel(or any of my other panels) and that way have diffrent case cenarios? I tried something like that last night but engine didn't understand me wink Needs more pointers?

And thanx again, you have helped me so much! The game I'm remaking as a practise project needs a LOT of these pulsating things (makers must have been obsessed with it!) and I realy was going crazy trying to make it work on my own. I'm also starting to understand how usefull the switch statments are, got some ideas where to use that later in my code... smile

Re: How to make pulsating text? [Re: 4gottenname] #271681
06/14/09 12:39
06/14/09 12:39
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Your first question is trick to explain, but I'll do my best.
function pulsate_text_stop(var,PANEL*); is what is called a "function prototype".
Its not a real function, its just pretending to be one, so the compiler knows its name and parameters.

Notice that my "pulsate_text" function calls on "pulsate_text_stop". It cant do this
until the compiler know about pulsate_text_stop.
BUT the real pulsate_text_stop comes AFTER pulsate_text so the compiler doesnt know it exists, and would fail.
BUT, by putting a prototype of pulsate_text_stop in before pulsate_text, then the compiler knows how to use
pulsate_text_stop, and then continues compiling.
Then, when it finds the next pulsate_text_stop, the compiler compiles it, over-writing any references to
the prototype. All Good!
Normally one would say, "just put pulsate_text_stop in front of pulsate_text!".
I cant do that, because pulsate_text_stop contains a reference to pulsate_text, and then I would
just have the same problem again. Catch-22. Thats why we use prototypes...


Second question would take a lot of explaining too, but I will tell you this following code-snippet
WILL work, if you created another panel called "options_panel" and gave it some buttons and text's.
Code:
function pulsate_text(var butt_over, PANEL* this_pan)
{
	proc_kill((void*)pulsate_text);
	pulsate_text_stop(butt_over, this_pan);	//reset all text sizes for this panel
	//
	TEXT* this_text;
	switch(this_pan)
	{
		case start_panel:
			switch(butt_over)
			{	
				case 1:		this_text = newgame_txt;
				case 2:		this_text = loadgame_txt;
				case 3:		this_text = options_txt;
			}	
		case options_panel:
			switch(butt_over)
			{	
				case 1:		this_text = set_resolution_txt;
				case 2:		this_text = set_sounds_txt;
				case 3:		this_text = set_controls_txt;
			}
	}
	//
	while(1)
	{
		this_text.font = medium44_font;		wait (-0.2);
		this_text.font = large50_font;		wait (-0.2);
		this_text.font = medium44_font;		wait (-0.2);
		this_text.font = normal38_font;		wait (-0.2);
	}
}

Does that answer the second question?

I think that will do for this post anyways...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: How to make pulsating text? [Re: EvilSOB] #271682
06/14/09 12:44
06/14/09 12:44
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
I just noticed, the above "multi-panel" code, would actually allow multiple
panels on the screen AT ONCE, with only one "pulsating" selection between them.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: How to make pulsating text? [Re: EvilSOB] #271724
06/14/09 18:10
06/14/09 18:10
Joined: Jun 2009
Posts: 22
Finland
4gottenname Offline OP
Newbie
4gottenname  Offline OP
Newbie

Joined: Jun 2009
Posts: 22
Finland
Haven't had the chanse to try it out but looks like it will do exactly what I wanted. Now I realy got a lot to study and work with for the next week/s smile
Good explanation again. I didn't notice the functions where calling each other but now you thought me how to make that work also. No more questions (atm wink ), I've taken advantage of your helpfulness far too much already. I'm sure others will find this topic and your anwsers usefull/interesting also.
I will have many more questions about programming later on but they will be in new topics.... grin
Thank you so much again!

Page 2 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1