Off Topic > Off Topic
Programming Megathread
<< < (6/241) > >>
otto-san:
allman style 4evr <33
Nilscripter:

--- Code: ---function Riddlerdidnothingwrong()
wrong = math.random(0,1) --lets set a random value
if wrong == 1 then --if the value is 1 then he did something wrong
print("he did something wrong")
end
if wrong == 0 then --vice versa
print("he did nothing wrong, he had the wrong people")
end
end --close the function

While wait(0.1) do --loop forever while not crashing the whole damn game.
print("Let us check his illegal status")
Riddlerdidnothingwrong() --calls the above function.
end --close the loop

--- End code ---
Foxscotch:

--- Quote from: Meta_KnightX on October 28, 2015, 10:01:47 PM ---Talk("Can you code like this?");
Talk("I thought so.");

--- End quote ---
def post():
    stuff_to_say = ['every', 'post', 'I', 'make', 'in', 'this', 'thread',
                    'from', 'now', 'on', 'will', 'be', 'in', 'python']
    return ' '.join(stuff_to_say)

print(post())
jk
--- Quote from: Nilscripter on October 28, 2015, 10:16:19 PM ---

--- End quote ---
ok FIRST off code tags are nasty
second where did all the whitespace go??
pch:
add haskell or I'll be sad
kevin 51l:
here's some basic Java code from one of my games that i made about 2.5 years ago.

if it's too long, tell me and i'll edit it down.


--- Code: ---public void updateBuffer() {
buffer.height = body.height;
buffer.width = body.width;
if (isJump) {
if (direction == 0)
buffer.x = body.x - 20;
else
buffer.x = body.x + 20;
} else {
if (direction == 0)
buffer.x = body.x - 10;
else
buffer.x = body.x + 10;
}
}

public void move(walls w) {
if (!isFalling()) {
body.x += xVelocity;
if (xVelocity > 0) {
xVelocity += 2;
} else if (xVelocity < 0) {
xVelocity -= 2;
}

updateBuffer();

if (!isJump) {
boolean safe = false;
for (Rectangle a : w.getList()) {
if (buffer.intersects(a)) {
safe = true;
break;
}
}
if (!safe) {
dead = true;
if (direction == 0)
xVelocity += 2;
else
xVelocity -= 2;
}
} else {
for (Rectangle a : w.getList()) {
if (a.intersects(buffer)) {
if (direction == 1)
body.x += (a.x - body.x - 10);
else
body.x -= (body.x - a.x - 20);
stop();
break;
}
}
}
} else {
if (direction == 1) {
if (xVelocity > 0)
xVelocity -= 4;
else if (xVelocity < -2)
xVelocity = 0;
} else {
if (xVelocity < 0)
xVelocity += 4;
else if (xVelocity > 2)
xVelocity = 0;
}
body.x += xVelocity;

if (yVelocity == 0)
yVelocity += 9;
else
yVelocity += 4;
body.y += yVelocity;
if (body.y > 380) {
body.width = 20;
body.height = 10;
body.y = 380;
}
}
}
--- End code ---

bonus points if you can kind of figure out what it's supposed to do
Navigation
Message Index
Next page
Previous page

Go to full version