Advertisement
Guest User

YOLOSWAG

a guest
Jul 2nd, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.72 KB | None | 0 0
  1. import processing.core.PApplet;
  2. import java.util.Random;
  3. import java.util.Scanner;
  4.  
  5. public class Project extends PApplet {
  6. Random randomGenerator = new Random();
  7.  
  8. //VARIABLES
  9. int xBar = 100;
  10. int topxBar = 100;
  11. // int topyBar = 800;
  12.  
  13. public float x = 400;
  14. public float y = 350;
  15.  
  16. public float speed = 7;
  17. public boolean moveLeft = false;
  18. public boolean moveRight = false;
  19. public boolean moveUp = false;
  20. public boolean moveDown = false;
  21. public boolean moving = false;
  22.  
  23. //CHARACTERS
  24. public boolean face = false;
  25. public boolean snowman = false;
  26. public boolean ship = false;
  27. //bars moving
  28.  
  29. int aBar = randomGenerator.nextInt(800);
  30. int bBar = randomGenerator.nextInt(800);
  31. int cBar = randomGenerator.nextInt(800);
  32. int dBar = randomGenerator.nextInt(800);
  33. int eBar = randomGenerator.nextInt(800);
  34. int zBar = randomGenerator.nextInt(70);
  35. int fBar = randomGenerator.nextInt(800);
  36. int gBar = randomGenerator.nextInt(800);
  37. int topzBar = randomGenerator.nextInt(400);
  38. int topyBar = randomGenerator.nextInt(400);
  39.  
  40. int change=1;
  41.  
  42. public void setup()
  43. {
  44. size(2000, 1000);
  45. background(0, 0, 0);
  46.  
  47. }
  48.  
  49. public void draw()
  50. {
  51. move();
  52. background(0, 0,0);
  53. drawBars();
  54.  
  55. /// ABAR MOVEMENT
  56. if(change==1)
  57. {
  58. aBar++;
  59. if (aBar==800)
  60. change=0;
  61. }
  62. if (change==0)
  63. {
  64. aBar--;
  65. if(aBar==0)
  66. change=1;
  67. }
  68.  
  69. /// BBAR MOVEMENT
  70. if(change==0)
  71. {
  72. bBar++;
  73. if (bBar==800)
  74. change=0;
  75. }
  76. if (change==1)
  77. {
  78. bBar--;
  79. if(bBar==0)
  80. change=1;
  81. }
  82.  
  83. /// CBAR MOVEMENT
  84. if(change==1)
  85. {
  86. cBar++;
  87. if (cBar==800)
  88. change=0;
  89. }
  90. if (change==0)
  91. {
  92. cBar--;
  93. if(cBar==0)
  94. change=1;
  95. }
  96.  
  97. /// DBAR MOVEMENT
  98. if(change==0)
  99. {
  100. dBar++;
  101. if (dBar==800)
  102. change=0;
  103. }
  104. if (change==1)
  105. {
  106. dBar--;
  107. if(dBar==0)
  108. change=1;
  109. }
  110.  
  111. /// EBAR MOVEMENT
  112. if(change==1)
  113. {
  114. eBar++;
  115. if (eBar==800)
  116. change=0;
  117. }
  118. if (change==0)
  119. {
  120. eBar--;
  121. if(eBar==0)
  122. change=1;
  123. }
  124.  
  125. /// FBAR MOVEMENT
  126. if(change==0)
  127. {
  128. fBar++;
  129. if (fBar==800)
  130. change=0;
  131. }
  132. if (change==1)
  133. {
  134. fBar--;
  135. if(fBar==0)
  136. change=1;
  137. }
  138.  
  139. /// GBAR MOVEMENT
  140. if(change==1)
  141. {
  142. gBar++;
  143. if (gBar==800)
  144. change=0;
  145. }
  146. if (change==0)
  147. {
  148. gBar--;
  149. if(gBar==0)
  150. change=1;
  151. }
  152. translate(x, y);
  153. drawRocketShip();
  154. drawSnowMan();
  155. drawFace();
  156. }
  157.  
  158. public void drawBars()
  159. {
  160. //bottom bars
  161. fill(0, 170, 190);
  162. rect(400, 0, xBar, aBar);
  163. rect(600, 0, xBar, bBar);
  164. rect(800, 0, xBar, cBar);
  165. rect(1000, 0, xBar, dBar);
  166. rect(1200, 0, xBar, eBar);
  167. rect(1400, 0, xBar, fBar);
  168. rect(1600, 0, xBar, gBar);
  169.  
  170. //top bars
  171. fill(150, 10, 0);
  172. rect(400, aBar +200, topxBar, 1000);
  173. rect(600, bBar +200, topxBar,1000);
  174. rect(800, cBar +200, topxBar, 1000);
  175. rect(1000, dBar +200, topxBar, 1000);
  176. rect(1200, eBar +200, xBar, 1000);
  177. rect(1400, fBar +200, xBar, 1000);
  178. rect(1600, gBar +200, xBar, 1000);
  179.  
  180. }
  181. public void drawSnowMan()
  182. {
  183. if(snowman==true)
  184. {
  185. //body
  186. fill(255, 255, 255);
  187. stroke(255, 255, 255);
  188. ellipse(0, 5, 40, 40);
  189. ellipse(0, 20, 45, 45);
  190. ellipse(0, 40, 55, 55);
  191. //head
  192. ellipse(0, -25, 35, 35);
  193. //eyes
  194. fill(0, 0, 0);
  195. ellipse(-10, -30, 5, 5);
  196. ellipse(10, -30, 5, 5);
  197. //nose
  198. fill(204, 102, 0);
  199. rect(0, -25, 15, 5);
  200. //Arms
  201. fill(153, 76, 0);
  202. stroke(153, 76, 0);
  203. rect(0, 0, 40, 4);
  204. rect(-40, 0, 50, 4);
  205. fill(255, 255, 255);
  206. stroke(255, 255, 255);
  207. ellipse(0, 5, 40, 40);
  208. //buttons
  209. fill(8, 8, 8);
  210. ellipse(1,20, 5, 5);
  211. ellipse(1, 10, 5, 5);
  212. ellipse(1, 0, 5, 5);
  213. stroke(0, 0, 0);
  214. }
  215. }
  216. public void drawFace()
  217. {
  218. if(face==true)
  219. {
  220. //Draw TheSmilyFace
  221.  
  222. //Head
  223. stroke(0, 0, 0);
  224. fill(0, 0, 0);
  225. ellipse(0/4, 0/4, 29/4, 295/34);
  226. fill(255, 255, 0);
  227. ellipse(0/4, 0/4, 290/4, 290/4);
  228. //eyes
  229. fill(0, 0, 0);
  230. ellipse(-70/4, -40/4, 25/4, 25/4);
  231. ellipse(70/4, -40/4, 25/4, 25/4);
  232. fill(255, 255, 255);
  233. ellipse(-70/4, -40/4, 8/4, 8/4);
  234. ellipse(70/4, -40/4, 8/4, 8/4);
  235. //mouth
  236. fill(0, 0, 0);
  237. ellipse(-10/3, 50/3, 50, 20);
  238. fill(255, 255, 0);
  239. ellipse(-10/3, 50/3, 45, 15);
  240. fill(255, 255, 0);
  241. stroke(255, 255, 0);
  242. rect(-28, 5, 50, 10);
  243. stroke(0, 0, 0);
  244.  
  245. }
  246.  
  247. }
  248. public void drawRocketShip()
  249. {
  250. if(ship==true)
  251. {
  252. //wing color
  253. fill(70, 70, 70);
  254. //wings
  255. triangle(0, 0, 40, 10, 10, 50);
  256. triangle(0, 0, -40, 10, -10, 50);
  257. triangle(0, 0, 40, -10, 10, -50);
  258. triangle(0, 0, -40, -10, -10, -50);
  259. //Body color.
  260. stroke(8, 4, 2);
  261. fill(20, 20, 20);
  262. //Body
  263. ellipse(0, 0, 25, 25);
  264. //buttons
  265. }
  266. }
  267. public void keyPressed()
  268. {
  269. if(key == 'a')
  270. {
  271. moveLeft = true;
  272. moving = true;
  273. }
  274. if(key == 'd')
  275. {
  276. moveRight = true;
  277. moving = true;
  278. }
  279. if(key == 'w')
  280. {
  281. moveUp = true;
  282. moving = true;
  283. }
  284. if(key == 's')
  285. {
  286. moveDown = true;
  287. moving = true;
  288. }
  289. if(key == '1')
  290. {
  291.  
  292. snowman=true;
  293. face=false;
  294. ship=false;
  295. }
  296.  
  297. if(key == '2')
  298. {
  299. face=true;
  300. snowman=false;
  301. ship=false;
  302. }
  303.  
  304.  
  305. if(key=='3')
  306. {
  307. ship=true;
  308. snowman=false;
  309. face=false;
  310. }
  311. }
  312. public void keyReleased()
  313. {
  314. if(key =='a')
  315. {
  316. moveLeft = false;
  317. moving = false;
  318. }
  319. if(key == 'd')
  320. {
  321. moveRight = false;
  322. moving = false;
  323. }
  324. if(key == 'w')
  325. {
  326. moveUp = false;
  327. moving = false;
  328. }
  329. if(key == 's')
  330. {
  331. moveDown = false;
  332. moving = false;
  333. }
  334. // if(key == ' ')
  335. // {
  336. // snowman=false;
  337. // }
  338. }
  339.  
  340. public void move()
  341. {
  342. if(moveUp)
  343. {
  344. y -= speed;
  345. }
  346. if(moveDown)
  347. { y += speed;
  348.  
  349. }
  350. if(moveRight)
  351. { x += speed;
  352.  
  353. }
  354.  
  355. if(moveLeft)
  356. { x -= speed;
  357.  
  358.  
  359. }
  360. }
  361. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement