• Register
Forum Thread
  Posts  
Having some trouble with this code. (Forums : Coding & Scripting : Having some trouble with this code.) Locked
Thread Options
Jan 31 2015 Anchor

So...This is some code that I tried to code on my own for a sort of side project where...I'm honestly too embarrassed by the idea to describe it here, so I'll just present my problem. The actual formulas aren't in there yet, but I was wondering if someone could tell me these three things:
1. How to have the buttons activate a different formulas depending on which one is pushed.
2. How to display the name, HP (health points), and MU (Munitions) for each of the characters.
3. How to set a picture to each of the character
4. Isn't as important now, but it is how to change the character. I assume I can set it to the buttons later, but I can do it later.
Here is the coding I have done:
<HTML>
<HEAD>
[removed]
var Entity = function (hp, mu, sp, pp, fp, re, de, sl) {
this.hp = hp;
this.pp = pp;
this.mu = mu;
this.re = re;
this.fp = fp;
this.de = de;
this.sp = sp;
this.sl = sl;
};
var Mina = new Entity(15, 15, 3, 3, 3, 4, 1, 3);
var RH_Whelp = new Entity(15, 15, 3, 3, 3, 4, 1, 3);
var BC_Whelp = new Entity(15, 15, 3, 3, 3, 4, 1, 3);
var SS_Whelp = new Entity(15, 15, 3, 3, 3, 4, 1, 3);

var names;

var randomnumber = Math.floor(Math.random(10)*10);

var selectedmonster;
if (randomnumber <= 3){ selectedm
names = "Red Hand Whelp";
}
else if (randomnumber <= 6, > 3){ selectedm
names = "Blue Chest Whelp";
}
else if (randomnumber > 6){ selectedm
names = "Sand Stalker Whelp";
}

var battle = 1; var m
var playerdead = 0;
var playerempty = 0; var m

var playerturn = 1; var m
while (battle == 1){

while (playerturn == 1){

<form action="game_unkown.html" method="get">
Choose your action:



if ((isset($_RA['']) {
}

playerturn = 0; m
}
while (m 1){

playerturn = 1; m
}

if (selectedmonster.hp < 0){ m
battle = 0;
}

if (Mina.hp < 0){
playerdead = 1;
battle = 0;
}

if (Mina.mu < 0){
playerempty = 1
}

if (selectedmonster.mu < 0){ m
}
[removed]
</HEAD>
</HTML>

Apr 1 2015 Anchor

1. Do you mean screen buttons or keyboard keys/mouse?
2. Displaying in the screen as "Health: 50 Ammo: 30" for example?

Which engine do you use? Unity?

Bravo81
Bravo81 Founder of Greenlight Games Ltd
Apr 1 2015 Anchor

as it's HTML you would print something along the lines.
print ("HP:" + hp);

This is what you do between your statements for displaying the correct HTML.
The code is quite messy, I suggest you look into displaying HTML via Javascript functions.

--

Greenlight Games Ltd
Independent Games Studio
www.greenlightgames.co.uk
Greenlight Games

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.