Exemple #1
0
 def draw(self):
     jngl.draw(self.img, self.x, self.y + self.height)
     if self.active:
         xs = (self.anim_size*.13)-(.1*sin(self.animation))
         ys = self.anim_size*.2+(.1*sin(self.animation))
         y = self.y + (114-(64 * ys))
         x = self.x + (self.width-(16 * xs)) -12
         jngl.drawScaled(self.fire[int(self.animation)], x, y, xs, ys)
Exemple #2
0
 def draw(self):
     #jngl.setColor(200, 200, 200)
     #jngl.drawRect(self.x, self.y, self.width, self.height)
     for x in range(0, self.width, self.textureSize):
         for y in range(0, self.height, self.textureSize):
             jngl.draw(self.texture, self.x + x, self.y + y)
             if y == 0:
                 jngl.draw(self.gras_texture, self.x + x, self.y)
Exemple #3
0
def bouncingButton(x, y, img = "img/World/enter.png" ):
    jngl.pushMatrix()
    jngl.translate(x + 60, y + 80)
    factor = jngl.getTime() * 5.0 % 10
    if factor >= 5:
        factor = 5-(factor-5)
    jngl.scale(0.8 + factor/20.0)
    jngl.draw(img, -60, -80)
    jngl.popMatrix()
Exemple #4
0
 def draw(self, opacity = 0):
     jngl.setSpriteColor(255, 255, 255, self.opacity)
     if opacity >0:
         jngl.setSpriteColor(255, 255, 255, opacity)
     #jngl.drawRect(self.x, self.y, self.width, self.height)
     for x in range(0, self.width, self.textureSize):
         for y in range(0, self.height, self.textureSize):
             jngl.draw(self.texture, self.x + x, self.y + y)
             if y == 0:
                 jngl.draw(self.gras_texture, self.x + x, self.y)
     jngl.setSpriteColor(255,255,255,255)
Exemple #5
0
 def draw(self):
     jngl.setColor(255, 255, 255)
     x = self.x - self.width * (self.breathFactor - 1) / 2
     y = self.y + self.height * (self.breathFactor - 1)
     xfactor = self.breathFactor
     yfactor = 1 + (1 - self.breathFactor)
     if self.xspeed >= 0:
         jngl.drawScaled(self.filenames[self.currentFile], x, y, xfactor, yfactor)
     else:
         jngl.drawScaled(self.filenames[self.currentFile], x + self.width, y, -xfactor, yfactor)
     if self.hasKey:
         jngl.draw(RESOURCEWORLD + "key.png", self.x, self.y - 20)
Exemple #6
0
 def draw(self):
     #jngl.setColor(200, 200, 200)
     #jngl.drawRect(self.x, self.y, self.width, self.height)
     tex = self.texture
     if self.health < 500:
         tex = self.texture2
         if self.health < 250:
             tex = self.texture3
     for x in range(0, self.width, self.textureSize):
         for y in range(0, self.height, self.textureSize):
             jngl.draw(tex, self.x + x, self.y + y)
             if y == 0:
                 jngl.draw(self.gras_texture, self.x + x, self.y)
Exemple #7
0
 def showCredits(self):
     self.levelpack_finished = True
     if not self.enable_credits:
         self.sound.stopSounds()
         self.running = False
     SHOWCOUNT = 400
     showcount = SHOWCOUNT
     line = 0
     hcount = 0
     SPACE = 60
     lastTime = jngl.getTime()
     timePerStep = 0.01
     credits = [["Programming", "Jannik Waschkau", "Jan-Niklas Hasse", "Kolja Lubitz", "Carsten Pfeffer"],
         ["Leveldesign", "Jannik Waschkau", "Jan-Niklas Hasse", "Kolja Lubitz"],
         ["Graphics", "Carsten Pfeffer", "Kolja Lubitz","Jan-Niklas Hasse"],
         ["Music & Sound","Jannik Waschkau"],
         ["Graphics Engine (JNGL)","Jan-Niklas Hasse"],
         ["Thanks to","Hendrik Leibrandt","Malte 'MonkZ' Kuhn","Anika 'Chibi' Roosch","University Bremen"],
         ["Thanks to","Adrian Lubitz","Jannis Tanner"]]
     jngl.swapBuffers()
     jngl.translate(-jngl.getScreenWidth()/2, -jngl.getScreenHeight()/2)
     jngl.updateInput()
     jngl.setFontSize(50)
     while self.running:
         if jngl.getTime() - lastTime > timePerStep:
             lastTime += timePerStep
             jngl.setFontSize(50)
             for i in range(0, 3):
                 jngl.draw(RESOURCEWORLD + "Background.png", i*jngl.getWidth(RESOURCEWORLD + "Background.png"), 0)
             if line >= len(credits):
                 jngl.print("Thanks for Playing!!!", int((self.windowWidth/2) - jngl.getTextWidth("Thanks for Playing") / 2), (self.windowHeight/2))
                 self.levelpack_finished = True
                 if jngl.keyPressed(jngl.key.Any):
                     self.sound.stopSounds()
                     self.running = False
             elif jngl.keyPressed(jngl.key.Any):
                 line +=1
             else:
                 for word in credits[line]:
                     jngl.print(word, int((self.windowWidth/2) - jngl.getTextWidth(word) / 2), (self.windowHeight/2)-150+SPACE*hcount)
                     hcount += 1
                 hcount = 0
                 showcount-=1
                 if not showcount:
                     line+=1
                     showcount = SHOWCOUNT
             jngl.setFontSize(20)
             jngl.print("www.somyeol.com", self.windowWidth-180, self.windowHeight-30)
             jngl.swapBuffers()
             jngl.translate(-jngl.getScreenWidth()/2, -jngl.getScreenHeight()/2)
             jngl.updateInput()
Exemple #8
0
def canvas_preview(x, y, selected, i, free, folder):
    jngl.pushMatrix()
    jngl.translate(x + 50, y + 80)
    if selected:
        factor = jngl.getTime() * 5.0 % 10
        if factor >= 5:
            factor = 5-(factor-5)
        jngl.scale(0.9 + factor/40.0)
    jngl.draw("img/World/canvas_preview.png", -60, -80)
    if free:
        jngl.draw("img/gadgets/forbidden_bg.png", -90, -110)
        jngl.print(str(i+1), -60, -80)
        jngl.draw("img/gadgets/forbidden.png", -90, -110)
    else:
        jngl.print(str(i+1), -60, -80)
    if os.path.isfile("data/maps/"+ folder +"/"+ str(i+1) +".png"):
        jngl.draw("data/maps/"+ folder +"/"+ str(i+1) +".png", -20, -20)
    else:
        jngl.draw("img/World/spawner_2.png", -40, -60)
    jngl.popMatrix()
Exemple #9
0
 def printHighscore():
     x,y = (self.windowWidth/2) - 207, (self.windowHeight/2) - 140
     jngl.draw("img/World/highscore.png", x,y)
     hs = self.highscore.getLevelScore(self.levelNr)
     jngl.print("#".format(len(self.level.somyeols)), x+30, y+80)
     jngl.print("Score".format(len(self.level.somyeols)), x+100, y+80)
     jngl.print("Seconds".format(len(self.level.somyeols)), x+200, y+80)
     jngl.print("Rank".format(len(self.level.somyeols)), x+300, y+80)
     i = 1
     best_rank = hs[0].getRank()
     for score in hs:
         jngl.setFontColor(0,0,0)
         if new_score:
             if new_score == score:
                 jngl.setFontColor(255,50,50)
         jngl.print(str(i)+".", x+30, y+90+(30*i))
         #jngl.print(str(score.score), x+120, y+90+(30*i))
         jngl.print("{0}".format(score.score), x+100, y+90+(30*i))
         jngl.print("{0:.2f}".format(score.time), x+200, y+90+(30*i))
         jngl.print("{0:.2%}".format(score.getRank()/best_rank), x+300, y+90+(30*i))
         i += 1
     jngl.setFontColor(0,0,00)
Exemple #10
0
 def drawPreview(self):
     jngl.pushSpriteAlpha(100)
     jngl.draw(self.filename, self.x, self.y)
     jngl.popSpriteAlpha()
Exemple #11
0
 def draw(self):
     jngl.draw(self.img, self.x, self.y)
Exemple #12
0
 def drawPreview(self):
     jngl.draw(self.img, self.x, self.y + self.height)
     jngl.drawScaled(self.fire[0], self.x, self.y, 1, 1.8)
Exemple #13
0
 def drawBackground(self, cameray):
     for i in range(0, 3):
         jngl.draw(RESOURCEWORLD + "Background.png", i*jngl.getWidth(RESOURCEWORLD + "Background.png"), 0)
     jngl.draw(RESOURCEWORLD + "Wolken2.png", -350 + (jngl.getTime() * 5) % (self.game.windowWidth+jngl.getWidth(RESOURCEWORLD + "Wolken2.png")+350), 0)
     jngl.draw(RESOURCEWORLD + "Wolken2.png", -450 + (jngl.getTime() * 4) % (self.game.windowWidth+jngl.getWidth(RESOURCEWORLD + "Wolken2.png")+450), 100)
     jngl.draw(RESOURCEWORLD + "Wolken2.png", -650 + (jngl.getTime() * 3) % (self.game.windowWidth+jngl.getWidth(RESOURCEWORLD + "Wolken2.png")+650), 200)
     jngl.draw(RESOURCEWORLD + "Wolken2.png", -850 + (jngl.getTime() * 2) % (self.game.windowWidth+jngl.getWidth(RESOURCEWORLD + "Wolken2.png")+850), 150)
     jngl.draw(RESOURCEWORLD + "Wolken2.png", -1050 + (jngl.getTime() * 1) % (self.game.windowWidth+jngl.getWidth(RESOURCEWORLD + "Wolken2.png")+1050), 50)
Exemple #14
0
 def draw(self):
     jngl.draw(self.filename, self.x, self.y)
Exemple #15
0
for f in os.listdir("data/maps/"):
    pass
    if os.path.isdir("data/maps/" + f):
        levels.append(f)
level = 0
start = True
jngl.setBackgroundColor(0,0,0)
running = True
levelselect = False
while running:#not jngl.keyPressed(jngl.key.Escape):

    jngl.swapBuffers()
    jngl.updateInput()
    jngl.translate(-jngl.getScreenWidth()/2, -jngl.getScreenHeight()/2)
    while (not jngl.keyPressed(jngl.key.Return) or jngl.keyPressed(jngl.key.Escape)) and not levelselect:
        jngl.draw("img/World/splash.png", (game.windowWidth/2)-jngl.getWidth("img/World/splash.png")/2, (game.windowHeight/2)-jngl.getHeight("img/World/splash.png")/2)
        if jngl.keyPressed(jngl.key.Right):
            level += 1
            if level >= len(levels): level = 0
        elif jngl.keyPressed(jngl.key.Left):
            level -= 1
            if level < 0: level = len(levels)-1
        elif jngl.keyPressed(jngl.key.Escape):
            #import sys
            #jngl.hideWindow()
            running = False
            break
            #sys.exit()
        bouncingEnterButton((game.windowWidth/2) + 320, (game.windowHeight/2)+100)
        bouncingButton((game.windowWidth/2)-225, (game.windowHeight/2) + 115, "img/World/key_left_64.png")
        bouncingButton((game.windowWidth/2)+180, (game.windowHeight/2) + 115, "img/World/key_right_64.png")
Exemple #16
0
    def run(self):
        self.levelpack_finished = False
        self.highscore.loadHighscore(self.levelpack)
        self.levelpack_finished = False
        lastTime = jngl.getTime()
        needDraw = True
        timePerStep = 0.01
        counter = 0
        fps = 0
        start_time = time.time()
        seconds = 0
        min_fps_count = MIN_FPS
        self.moveCamera()
        while self.running:
            if min_fps_count and jngl.getTime() - lastTime > timePerStep:
                lastTime += timePerStep
                needDraw = True
                if jngl.keyPressed(jngl.key.Escape):
                    self.sound.stopSounds()
                    self.running = False
                if jngl.keyPressed("r"):
                    self.level.somyeols = []
                    self.level.points = 0

                self.moveCamera()
                self.calculateCollisionBounds()
                if not self.finish:
                    self.level.step()
                else:
                    for a in self.level.animations:
                        a.step(self.level.animations)
                    for o in self.level.objects:
                        o.step()

            elif needDraw:
                if not min_fps_count:
                    lastTime = jngl.getTime()
                min_fps_count = MIN_FPS
                self.sound.playSounds()
                self.checkMusic()
                jngl.setFontSize(20)
                needDraw = False

                self.level.drawBackground(self.cameray)
                jngl.pushMatrix()
                jngl.translate(self.windowWidth/2, self.windowHeight)
                jngl.scale(1 + (self.scale - 1) / 2)
                jngl.translate(self.camerax / 2, -self.windowHeight + self.cameray / 2)
                for i in range(-2, 3):
                    jngl.draw(RESOURCEWORLD + "mountains.png", i*1024, self.windowHeight-300)
                jngl.popMatrix()
                jngl.pushMatrix()
                jngl.scale(self.scale)
                jngl.translate(self.camerax, self.cameray)
                self.level.draw()
                #uncomment for visualization of boundingbox
##                jngl.setColor(255,0,0,150)
##                jngl.drawRect(self.bounds.x,self.bounds.y,self.bounds.width,self.bounds.height)
                jngl.popMatrix()

                jngl.pushSpriteAlpha(150)
                jngl.draw("img/World/canvas.png", -80, -100)
                jngl.print("Somyeols: {0}".format(len(self.level.somyeols)), 10, 10)
                jngl.draw("img/World/canvas.png", self.windowWidth - 200, -120)
                jngl.print("Level: {0}".format(self.levelNr), self.windowWidth - 140, 10)
                jngl.popSpriteAlpha()

                jngl.print("Time: %.2f"%(seconds), 10, 40)

                if self.finish:
                    if not self.testmode:
                        def printCentered(t, x, y):
                            jngl.print(t, int(x-jngl.getTextWidth(t) / 2), y)

                        def printHighscore():
                            x,y = (self.windowWidth/2) - 207, (self.windowHeight/2) - 140
                            jngl.draw("img/World/highscore.png", x,y)
                            hs = self.highscore.getLevelScore(self.levelNr)
                            jngl.print("#".format(len(self.level.somyeols)), x+30, y+80)
                            jngl.print("Score".format(len(self.level.somyeols)), x+100, y+80)
                            jngl.print("Seconds".format(len(self.level.somyeols)), x+200, y+80)
                            jngl.print("Rank".format(len(self.level.somyeols)), x+300, y+80)
                            i = 1
                            best_rank = hs[0].getRank()
                            for score in hs:
                                jngl.setFontColor(0,0,0)
                                if new_score:
                                    if new_score == score:
                                        jngl.setFontColor(255,50,50)
                                jngl.print(str(i)+".", x+30, y+90+(30*i))
                                #jngl.print(str(score.score), x+120, y+90+(30*i))
                                jngl.print("{0}".format(score.score), x+100, y+90+(30*i))
                                jngl.print("{0:.2f}".format(score.time), x+200, y+90+(30*i))
                                jngl.print("{0:.2%}".format(score.getRank()/best_rank), x+300, y+90+(30*i))
                                i += 1
                            jngl.setFontColor(0,0,00)
                        if self.finish_highscore:
                            printHighscore()
                        else:
                            x,y = (self.windowWidth/2) - (jngl.getWidth("img/World/canvas.png")/2), (self.windowHeight/2) - (jngl.getHeight("img/World/canvas.png")/2)
                            jngl.draw("img/World/canvas.png", self.windowWidth/2 - 137, self.windowHeight/2 - 92)
                            printCentered("FINAL SCORE", x+(jngl.getWidth("img/World/canvas.png")/2), y+20)
                            printCentered("NEEDED: 100", x+(jngl.getWidth("img/World/canvas.png")/2), y+140)
                            jngl.setFontSize(50)
                            printCentered(str(self.level.points), x+(jngl.getWidth("img/World/canvas.png")/2), y+70)
                        bouncingEnterButton(x+50, y+jngl.getHeight("img/World/canvas.png")+50)
                        if jngl.keyPressed(jngl.key.Return) and self.finish_highscore:
                            self.levelpack_finished = not self.loadNextLevel()
                            start_time = time.time()

                        elif jngl.keyPressed(jngl.key.Return):
                            if self.level.points < self.level.needed_points:
                                self.levelNr -= 1
                                self.levelpack_finished = not self.loadNextLevel()
                                start_time = time.time()
                            else:
                                self.finish_highscore = True
                                # HIGHSCORE
                                new_score = self.highscore.newHighscore(self.levelNr, seconds, self.level.points)
                                if new_score:
                                    self.highscore.saveHighscore(self.levelpack)
                                time.sleep(.5)
                    else:self.running=False
                else:
                    seconds = time.time()-start_time

                fps += jngl.getFPS() / 50
                counter -= 1
                if counter < 0:
                    counter = 50
                    jngl.setTitle("Somyeol2D {0} - FPS: {1}".format(self.version, int(fps)))
                    fps = 0
                jngl.setFontSize(20)
                jngl.print("Press F1 for Help", 10, self.windowHeight-30)
                if jngl.keyDown(jngl.key.F1):
                    jngl.draw(HELPSCREEN, (self.windowWidth/2)-jngl.getWidth(HELPSCREEN)/2, (self.windowHeight/2)-jngl.getHeight(HELPSCREEN)/2)

                #uncomment for visualization of collision-count
                #colcount = 0
                #for o in self.level.objects:
                #    if o.canCollide:
                #        colcount+=1
                #jngl.print(str(colcount), self.windowWidth-680, self.windowHeight-50)
                jngl.print("www.somyeol.com", self.windowWidth-180, self.windowHeight-30)

                jngl.swapBuffers()
                jngl.translate(-jngl.getScreenWidth()/2, -jngl.getScreenHeight()/2)
                jngl.updateInput()
            else:
                jngl.sleep(1)
            min_fps_count-=1
        self.sound.stopSounds()
Exemple #17
0
 def drawPreview(self):
     jngl.setSpriteColor(100, 100, 255, 20)
     jngl.draw(self.filename, self.x, self.y)
     jngl.setSpriteColor(255, 255, 255, 255)
Exemple #18
0
 def draw(self):
     jngl.draw(self.filenames[self.i], self.x-jngl.getWidth(self.filenames[self.i])/2, self.y-jngl.getHeight(self.filenames[self.i])/2)