dMZX Forums: My bug filled amateur shuriken (throwing star) engine - help?! - dMZX Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

My bug filled amateur shuriken (throwing star) engine - help?!

#1 User is offline   OhGoodShepherd 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 9
  • Joined: 29-January 16

Posted 24 March 2016 - 07:53 PM

My sons (7 and 4) and I are using MZX as a fun homeschooling experiment.

I've created the attached shuriken engine (with their assistance) but am running into some problems.

As it is it does many of the things we desire:

  • Throws shurikens in any direction
  • Shurikens sink into walls
  • Shurikens can be recovered
  • Shurikens send the robots they hit to a specific line of code
  • Shurikens make sounds upon being thrown and hitting a wall
  • Shurikens can not be thrown when right next to a wall or another "dropped"/fallen shuriken
  • Shurikens spin when thrown


but we are seeing some bugs that we can't get rid of:

  • The first throw in each direction doesn't function (just spins in place) (thx Dr Lancer-X)
  • Could only get shuriken counter decreasing to work when they hit (not when thrown)
  • Shurikens stopping when hitting a "dropped" shuriken acts buggy (sometimes they keep spinning)
  • Due to where my "dec shurikens 1" line is placed the counter sometimes "wraps" around instead of stopping at 0
  • When standing near a robot at any side you can not fire due to checking for nearby robots
  • When firing robots on other sides are also damaged
  • Probably many other bugs and coding mistakes I'm not yet aware of!


I can hear certain forum users who I feel like I've gotten to know a bit just by reading their posts (Dr Lancer-X) telling me that I'm over-complicating things ...

I know that I could probably make this work with 1 or 2 robots but I have not been able to get it working.

I also know that I should probably be using overlay but I had a lot of problems getting that to work too.

My plan is to start over from scratch and take what I have learned and attempt to make this better but I thought I would ask some of you pros for advice first.

Feel free to be brutal, we're still learning and honestly my 7 year old has a much better understanding of this than I do - I've tried and failed to learn to code for many years!

I've attached my sample board - if anyone wants to take a peek and give advice/fix this/laugh at us - feel free!
Thanks.

Attached File(s)

  • Attached File  SHUR.zip (23.31K)
    Number of downloads: 1

This post has been edited by OhGoodShepherd: 26 March 2016 - 06:48 AM

0

#2 User is offline   Dr Lancer-X 

  • 電波、届いた?
  • Group: DigiStaff
  • Posts: 8,936
  • Joined: 20-March 02
  • Location:ur mom nmiaow

Posted 24 March 2016 - 09:37 PM

Just took a quick glance, but I think you might be mistaken about how 'duplicate self' works exactly. The duplicated robot does not continue from the same line as the original robot- in fact, it starts at the beginning.

As a result, this:
rel to player
duplicate self at 0 -1
walk NORTH


will cause the original robot to duplicate itself at 0,-1 and then walk north. The duplicate, on the other hand, starts at the beginning (at the :check label) and won't walk anywhere.

However, the duplicate robot does inherit things like the walk direction of the original robot. As a result, you can do something like this:
walk NORTH
rel to player
duplicate self at 0 -1
walk IDLE


The original robot will start walking, duplicate itself, then stop walking all in the same cycle (so it won't actually walk at all). The duplicate robot, on the other hand, will continue to walk but will start at the top and will therefore continue.

The next thing causing you problems is that all shurikens in a particular direction will respond to 'go' messages, which means that e.g. every north shuriken will attempt to duplicate itself in response to you firing a north shuriken.

A possible solution to this is similar to the walk solution described previously- the duplicate robot inherits the zapped/restored state of labels from the parent robot, so you can do this:
walk NORTH
zap "go" 1
rel to player
duplicate self at 0 -1
restore "go" 1
walk IDLE


This will ensure that child shurikens do not respond to "go" messages.
Posted Image
<Malwyn> Yes, yes. Don't worry I'd rather masturbate with broken glass than ask you for help again. :(
0

#3 User is offline   OhGoodShepherd 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 9
  • Joined: 29-January 16

Posted 25 March 2016 - 12:51 AM

View PostDr Lancer-X, on 24 March 2016 - 04:37 PM, said:

A possible solution to this is similar to the walk solution described previously- the duplicate robot inherits the zapped/restored state of labels from the parent robot, so you can do this:
walk NORTH
zap "go" 1
rel to player
duplicate self at 0 -1
restore "go" 1
walk IDLE


This will ensure that child shurikens do not respond to "go" messages.


Hey, thanks!

I was hoping you would reply.

Reading through other forum posts you've always had simple answers to seemingly complicated problems.

This worked like a charm for getting the first throw to work, I appreciate it!
0

#4 User is offline   OhGoodShepherd 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 9
  • Joined: 29-January 16

Posted 26 March 2016 - 04:48 PM

I changed each robot's "go" to a unique label, such as "gonorth", "gosouth" so on...

I was hoping that might remove some of my issues but no such luck!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users