Previous Thread
Next Thread
Print Thread
Page 2 of 2 1 2
Joined: Feb 2014
Posts: 712
Likes: 13
G
Senior Member
OP Online Content
Senior Member
G
Joined: Feb 2014
Posts: 712
Likes: 13
I did my best to make a "depth" path where the radius is proportional to the depth of the cam channel. I think it works pretty well, eyeballing it and using the depths given in Sean's pictures.

[Linked Image from i.imgur.com]

Varying the height based on the depth path simulates the "pecking" motion.

Now to try to figure out some pseudo physics to make it bounce back and forth.



Last edited by Golden Child; 12/31/21 03:03 AM.
Joined: Feb 2014
Posts: 712
Likes: 13
G
Senior Member
OP Online Content
Senior Member
G
Joined: Feb 2014
Posts: 712
Likes: 13
Comparing mame with the real thing at 0.25 speed:


Joined: Feb 2014
Posts: 712
Likes: 13
G
Senior Member
OP Online Content
Senior Member
G
Joined: Feb 2014
Posts: 712
Likes: 13
And adding a spring effect with f = -kx for a little bounce. If you change the constants the bouncing can get really wild.

Code
leaderx = scale(depthtable[(machine.output:get_value("motor_pos")+radiustableoffset)%100+1],0,300,0,.05)

followerx = followerx or 0
velocity = velocity or 0
mass = 2.6 
k = .25  
force = -k*(followerx-leaderx)
accel = force / mass

velocity = velocity + accel
followerx = followerx + velocity

damping = .05

followerx = followerx * (1-damping)

if followerx < -1.0 then followerx = -1.0 end
if followerx > 1.0 then followerx = 1.0 end

			b:set_xy(myx0,myy0,myx1,myy1+followerx)
			
			return b
		end)



1 member likes this: R. Belmont
Joined: Oct 2020
Posts: 17
Likes: 3
Member
Offline
Member
Joined: Oct 2020
Posts: 17
Likes: 3
Can you make it so the box doesn't get taller / shorter? Or at least hide the fact that it does that? Just curious... otherwise I think it looks cool

Joined: Feb 2014
Posts: 712
Likes: 13
G
Senior Member
OP Online Content
Senior Member
G
Joined: Feb 2014
Posts: 712
Likes: 13
Thanks!

Yes, I was planning on removing the square, possibly just making it invisible. It seems that svgs "auto-size" themselves to the bounding box so I need a box around it, but it shouldn't be hard to set the alpha to zero. Once I do that, you should just see the chicken. The other strategy would be to put a same color box underneath so you wouldn't see the bottom edge moving.

I also added a rotational spring so that it wiggles a bit rotationally.

1 member likes this: MrBogi
Joined: Feb 2014
Posts: 712
Likes: 13
G
Senior Member
OP Online Content
Senior Member
G
Joined: Feb 2014
Posts: 712
Likes: 13
I accidentally left a color specifier for a layout element that had an svg image and the colors were all messed up and I couldn't figure out why. Then I realized that the stray color tag was there. Sure enough, it's documented in the mame layout docs:

Quote
For image components, the colour of the image pixels is multiplied by the specified colour. If no such element is present, the colour defaults to opaque white.

I was brainstorming and realized that this could be extremely useful to show/hide layout elements.

Just set the alpha to zero in a set_color_callback() function with

"return emu.render_color(1,1,1,1) " for opaque (alpha = 1)
"return emu.render_color(0,1,1,1) " for invisible (alpha = 0)


So for example to vary the transparency of an item:

Code

function code_pressed(code) return machine.input:code_pressed(machine.input:code_from_token(code)) end

	file.views["Internal Layout"].items["chicken"]:set_color_callback(
		function () 
		
		curcolor = curcolor or 1  -- start out with 1
		
		if code_pressed("KEYCODE_T") then curcolor = 1.0 end
		if code_pressed("KEYCODE_R") then curcolor = 0.7 end
		if code_pressed("KEYCODE_E") then curcolor = 0.5 end
		if code_pressed("KEYCODE_W") then curcolor = 0.2 end		
		if code_pressed("KEYCODE_Q") then curcolor = 0.0 end
		
		return emu.render_color(curcolor,1,1,1) 
		end)

Joined: Feb 2014
Posts: 712
Likes: 13
G
Senior Member
OP Online Content
Senior Member
G
Joined: Feb 2014
Posts: 712
Likes: 13
Playing around with inkscape

[Linked Image from i.imgur.com]

1 member likes this: MrBogi
Page 2 of 2 1 2

Link Copied to Clipboard
Who's Online Now
2 members (gspat, 1 invisible), 23 guests, and 2 robots.
Key: Admin, Global Mod, Mod
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Forum Statistics
Forums9
Topics9,018
Posts118,430
Members5,010
Most Online890
Jan 17th, 2020
Forum Host
These forums are hosted by www.retrogamesformac.com
Forum hosted by www.retrogamesformac.com